You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
753 B

3 years ago
  1. #ifndef SOCKETCLIENT_H_
  2. #define SOCKETCLIENT_H_
  3. #include <sys/socket.h>
  4. #include <sys/types.h>
  5. #include <netinet/in.h>
  6. #include <netdb.h>
  7. #include <string>
  8. namespace exploringBB {
  9. class SocketClient {
  10. private:
  11. int socketfd;
  12. struct sockaddr_in serverAddress;
  13. struct hostent *server;
  14. std::string serverName;
  15. int portNumber;
  16. bool isConnected;
  17. public:
  18. SocketClient(std::string serverName, int portNumber);
  19. virtual int connectToServer();
  20. virtual int disconnectFromServer();
  21. virtual int send(std::string message);
  22. virtual std::string receive(int size);
  23. bool isClientConnected() { return this->isConnected; }
  24. virtual ~SocketClient();
  25. };
  26. }
  27. #endif /* SOCKETCLIENT_H_ */