Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. while ((len = stream->receive(input, sizeof(input)-1)) > 0 )
  2. {
  3. input[len] = NULL;
  4. //Code Addition by Srini starts here
  5.  
  6.  
  7. //Client declaration
  8. TCPConnector* connector_client = new TCPConnector();
  9. printf("ip_client = %stport_client = %stport_client_int = %dn", ip_client.c_str(), port_client.c_str(),atoi(port_client.c_str()));
  10. TCPStream* stream_client = connector_client->connect(ip_client.c_str(), atoi(port_client.c_str()));
  11.  
  12. //Client declaration ends
  13. if (stream_client)
  14. {
  15. //message = "Is there life on Mars?";
  16. //stream_client->send(message.c_str(), message.size());
  17. //printf("sent - %sn", message.c_str());
  18.  
  19. stream_client->send(input, sizeof(input));
  20. printf("sent - %sn", input);
  21. len = stream_client->receive(line, sizeof(line));
  22. line[len] = NULL;
  23. printf("received - %sn", line);
  24. delete stream_client;
  25. }
  26.  
  27. //Code Additon by Srini ends here
  28.  
  29. stream->send(line, len);
  30. printf("thread %lu, echoed '%s' back to the clientn",
  31. (long unsigned int)self(), line);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement