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.

57 lines
1.4 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __SERVERPORT_H_INCL__
  2. #define __SERVERPORT_H_INCL__
  3. #include <stdio.h> // standard input / output functions
  4. #include <stdlib.h>
  5. #include <string.h> // string function definitions
  6. #include <fcntl.h> // File control definitions
  7. #include <errno.h> // Error number definitions
  8. #ifdef __linux__
  9. #include <unistd.h> // UNIX standard function definitions
  10. #include <sys/types.h>
  11. #include <sys/socket.h>
  12. #include <sys/ioctl.h>
  13. #include <netinet/in.h>
  14. #include <netdb.h>
  15. #else
  16. //#include <winsock.h>
  17. #include <winsock2.h>
  18. #include <ws2tcpip.h>
  19. #include <windows.h>
  20. #endif
  21. #include "transportSocket.h"
  22. /**
  23. * TODO: Add class description
  24. *
  25. * @author Gagua
  26. */
  27. class serverPort : public transportSocket {
  28. private:
  29. basicLogCollection *m_pLog;
  30. #ifdef __linux__
  31. int m_nSocketFD;
  32. #else
  33. SOCKET m_nSocketFD;
  34. #endif
  35. bool m_bKeepAlive;
  36. bool m_bInitComplete;
  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){ return m_bKeepAlive; };
  51. };
  52. #endif // __SOCKETPORT_H_INCL__