ipv4_tcpserver.h
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 #ifndef IPV4IPV4_TCPSERVER_H
00020 #define IPV4IPV4_TCPSERVER_H
00021 
00022 #include <conexus/ipv4_address.h>
00023 #include <conexus/endpointserver.h>
00024 #include <conexus/ipv4_tcp.h>
00025 
00034 namespace Conexus
00035 {
00036 
00037   namespace IPv4
00038   {
00039 
00047     class TCPServer: public Conexus::EndpointServer
00048     {
00049 
00050       protected:
00051 
00052         TCPServer( uint32_t address, uint16_t port, int backlog );
00053 
00054         TCPServer( const std::string& address, uint16_t port, int backlog );
00055 
00056       public:
00057         typedef ConexusPointer<TCPServer> pointer;
00058 
00059         CONEXUS_ENDPOINTSERVER_GENERIC_CREATE();
00060 
00061         static pointer create( uint16_t port = 0, int backlog = 5 );
00062 
00063         static pointer create( uint32_t address, uint16_t port, int backlog = 5 );
00064 
00065         static pointer create( const std::string& address, uint16_t port=0, int backlog = 5 );
00066 
00067         virtual ~TCPServer();
00068 
00069         virtual Address& address();
00070 
00071         virtual void set_address( Address addr );
00072 
00073         virtual void set_address( uint32_t addr, uint16_t port );
00074 
00075         virtual void set_address( const std::string& addr, uint16_t port );
00076 
00077         int backlog();
00078 
00079         TCP::pointer listener();
00080 
00081         const TCP::pointer listener() const;
00082 
00084         TCP& listener_ref();
00085 
00086         void enable_reuse_address( bool enable=true );
00087 
00088       protected:
00089         TCP::pointer m_listener;
00090 
00091         int m_backlog;
00092 
00093         virtual void pre_start();
00094 
00095         virtual void post_stop();
00096 
00097         virtual void service_thread_main();
00098 
00099         virtual TCP::pointer create_accepted_endpoint( int fd );
00100 
00101 
00102     };
00103 
00104   } 
00105 
00106 } 
00107 
00108 #endif