Skip to content

Commit

Permalink
Small change
Browse files Browse the repository at this point in the history
  • Loading branch information
geet authored and geet committed Sep 11, 2014
1 parent b13d59d commit 3bb408f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 4 additions & 1 deletion cpp/zmq/req-rep/client_connect_multiple_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 6 additions & 5 deletions cpp/zmq/req-rep/server_arg_port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 3bb408f

Please sign in to comment.