TCPServer.h 951 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // Copyright @ 2015 Hangzhou Topzen Ltd.
  3. // Author: Tang (tang@hztopzen.com) @ 2015-07
  4. //
  5. #ifndef __TCPSERVER_H
  6. #define __TCPSERVER_H
  7. #include "Socket.h"
  8. namespace tzc {
  9. class TCPSocket;
  10. class DECLDLL TCPServer : public Socket
  11. {
  12. public:
  13. TCPServer(TZ_Uint32 type = STYPE_TCPS);
  14. virtual ~TCPServer();
  15. virtual TZ_INT Bind(const SockAddress & addr);
  16. virtual TZ_INT Connect(const SockAddress & raddr);
  17. virtual TZ_INT RecvBytes(TZ_BYTE * buffer, TZ_Uint32 length);
  18. virtual TZ_INT SendBytes(const TZ_BYTE * buffer, TZ_Uint32 length);
  19. // the socket type must be UDP or UNIX_UDP
  20. virtual TZ_INT SendBytes(const TZ_BYTE * buffer, TZ_Uint32 length,
  21. const SockAddress & raddr);
  22. public:
  23. TZ_INT Listen(TZ_Uint32 backlog);
  24. TCPSocket * Accept(SockAddress & raddr);
  25. private:
  26. TCPServer(const Socket & sock);
  27. TCPServer & operator = (const Socket & sock);
  28. };
  29. }; // namespace tzc
  30. #endif /* ----- #ifndef __TCPSERVER_H ----- */