client.cpp 491 B

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // Created by zx on 22-12-23.
  3. //
  4. #include <iostream>
  5. #include <signal.h>
  6. #include "TCPClient.h"
  7. TCPClient tcp1,tcp2;
  8. void sig_exit(int s)
  9. {
  10. tcp1.exit();
  11. tcp2.exit();
  12. exit(0);
  13. }
  14. int main(int argc, char *argv[])
  15. {
  16. signal(SIGINT, sig_exit);
  17. tcp1.setup("127.0.0.1",33000);
  18. tcp2.setup("127.0.0.1",34000);
  19. while(1)
  20. {
  21. //tcp.Send(argv[3]);
  22. string rec = tcp1.receive();
  23. if( rec != "" )
  24. {
  25. cout << rec << endl;
  26. }
  27. usleep(1000*1);
  28. }
  29. return 0;
  30. }