i setup interprocess
communication using sockets
between server
, several client
processes
using c++
. server
, client
processes running on on same windows 7
computer. intention vector
of data held server
, transmitted each client
. time-to-time vector
held server
extended (pushback()) further data elements
, data need transmitted each client
. can provide links examples of how this, relevant reference materials or simple toy
code example?
edit: after further investigation have found winsock
suitable. there plenty of examples revealed google search on how setup winsock
server
& client
arrangement. there less information on how pass data through sockets
. can expand on how synchronize vector
between server
& clients
through socket
communication? each client
need indicate element
index has been passed , server
serve elements client
did not have.
if want control protocol above tcp/udp layer, try libevent or boost.asio. if more interested in being able pass messages, @ zeromq or amqp.
server example using zeromq
#include <iostream> #include <zmq.hpp> int main(int argc, const char* argv[]) { // create zeromq network context using 1 thread zmq::context_t ctx(1); // 'upstream' i.e. receiver zmq::socket_t sock(ctx, zmq_upstream); sock.connect("tcp://localhost:12345"); zmq::message_t msg; while (sock.recv(&msg)) { std::cout << "rx: " << (const char*)msg.data() << std::endl; } }
Comments
Post a Comment