conexus logo

ipv4_tcpserver.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2001 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This file is part of the conexus library.                             *
00006  *                                                                         *
00007  *   The conexus library is free software; you can redistribute it and/or  *
00008  *   modify it under the terms of the GNU General Public License           *
00009  *   version 3 as published by the Free Software Foundation.               *
00010  *                                                                         *
00011  *   The conexus library is distributed in the hope that it will be        *
00012  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty   *
00013  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   *
00014  *   General Public License for more details.                              *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU General Public License     *
00017  *   along with this software. If not see <http://www.gnu.org/licenses/>.  *
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   } // namespace IPv4
00105 
00106 } // namespace Conexus
00107 
00108 #endif

Generated on Wed Jul 8 15:50:07 2009 for conexus by doxygen 1.5.8