diff --git a/cpp/zmq/req-rep/client_connect_multiple_server.cpp b/cpp/zmq/req-rep/client_connect_multiple_server.cpp index 1cabd5f..e200bc0 100644 --- a/cpp/zmq/req-rep/client_connect_multiple_server.cpp +++ b/cpp/zmq/req-rep/client_connect_multiple_server.cpp @@ -25,9 +25,12 @@ int main (int argc, char *argv[]) socket.connect(transport); } + char request_data[1024]; + i = 0; while (true){ zmq::message_t request (1024); - memcpy ((void *) request.data (), "Hello", 6); + snprintf(request_data, 1024, "Hello %08d", i++); + memcpy ((void *) request.data (), request_data, strlen(request_data)); socket.send (request); zmq::message_t reply; socket.recv (&reply); diff --git a/cpp/zmq/req-rep/server_arg_port.cpp b/cpp/zmq/req-rep/server_arg_port.cpp index 6e2b610..d1ccabe 100644 --- a/cpp/zmq/req-rep/server_arg_port.cpp +++ b/cpp/zmq/req-rep/server_arg_port.cpp @@ -19,17 +19,18 @@ int main (int argc, char *argv[]) snprintf(transport, 255, "tcp://*:%s", argv[1]); socket.bind (transport); - char response[512]; - memset(response, 0, 512); - snprintf(response, 512, "Response from server lisetning on %s", argv[1]); + char response[2048]; + memset(response, 0, 2048); + snprintf(response, 2048, "Response from server lisetning on %s", argv[1]); int i = strlen(response); int times = 0; while (true){ zmq::message_t request; socket.recv (&request); - zmq::message_t reply (512); - snprintf(response + i , 512, " #%d", times++); + zmq::message_t reply (2048); + snprintf(response + i , 2048, " #%d -- request data: %s", + times++, (char *)request.data()); memcpy ((void *) reply.data (), response, strlen(response)); socket.send (reply); }