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.

68 lines
1.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __SERVERPORT_H_INCL__
  2. #define __SERVERPORT_H_INCL__
  3. #include <errno.h> // Error number definitions
  4. #include <fcntl.h> // File control definitions
  5. #include <stdio.h> // standard input / output functions
  6. #include <stdlib.h>
  7. #include <string.h> // string function definitions
  8. #ifdef __linux__
  9. #include <netdb.h>
  10. #include <netinet/in.h>
  11. #include <sys/ioctl.h>
  12. #include <sys/socket.h>
  13. #include <sys/types.h>
  14. #include <unistd.h> // UNIX standard function definitions
  15. #else
  16. // #include <winsock.h>
  17. #include <windows.h>
  18. #include <winsock2.h>
  19. #include <ws2tcpip.h>
  20. #endif
  21. #include "../transport/transportSocket.h"
  22. /**
  23. * TODO: Add class description
  24. *
  25. * @author Gagua
  26. */
  27. class serverPort : public transportSocket
  28. {
  29. private:
  30. basicLogCollection * m_pLog;
  31. #ifdef __linux__
  32. int m_nSocketFD;
  33. #else
  34. SOCKET m_nSocketFD;
  35. #endif
  36. bool m_bKeepAlive;
  37. protected:
  38. int sendBlock(unsigned char * Data, int DataSize);
  39. int recptBlock(unsigned char * Buffer, int * BufferLength);
  40. public:
  41. // Constructor
  42. #ifdef __linux__
  43. explicit serverPort(int AcceptedSocket);
  44. #else
  45. explicit serverPort(SOCKET AcceptedSocket);
  46. #endif
  47. // Destructor
  48. virtual ~serverPort();
  49. void setKeepAlive(bool Param);
  50. bool getKeepAlive(void)
  51. {
  52. return m_bKeepAlive;
  53. }
  54. virtual bool create(void);
  55. };
  56. #endif // __SOCKETPORT_H_INCL__