TCPClient.h 611 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef TCP_CLIENT_H
  2. #define TCP_CLIENT_H
  3. #include <iostream>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <unistd.h>
  7. #include <string.h>
  8. #include <sys/types.h>
  9. #include <sys/socket.h>
  10. #include <netinet/in.h>
  11. #include <arpa/inet.h>
  12. #include <netdb.h>
  13. #include <netdb.h>
  14. #include <vector>
  15. using namespace std;
  16. class TCPClient
  17. {
  18. private:
  19. int sock;
  20. std::string address;
  21. int port;
  22. struct sockaddr_in server;
  23. public:
  24. TCPClient();
  25. bool setup(string address, int port);
  26. bool Send(string data);
  27. string receive(int size = 4096);
  28. string read();
  29. void exit();
  30. };
  31. #endif