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 CONEXUSNSPRTCP_H 00020 #define CONEXUSNSPRTCP_H 00021 00022 #include <conexus-nspr/socket.h> 00023 00024 namespace Conexus { 00025 00026 namespace NSPR { 00027 00035 class TCP : public Socket { 00036 protected: 00037 00038 friend class TCPServer; 00039 00040 TCP( uint32_t host, uint16_t port ); 00041 00042 TCP( const std::string& host, uint16_t port ); 00043 00044 public: 00045 00046 typedef ConexusPointer<TCP> pointer; 00047 00048 CONEXUS_ENDPOINT_GENERIC_CREATE(); 00049 00050 static pointer create( uint16_t port = 0 ); 00051 00052 static pointer create( uint32_t host, uint16_t port ); 00053 00054 static pointer create( const std::string& host, uint16_t port ); 00055 00056 virtual ~TCP() throw(); 00057 00064 virtual bool shutdown( ReadWrite read_write=READ_WRITE ); 00065 00066 virtual void open() throw (open_exception); 00067 00068 virtual void connect() throw ( connect_exception ); 00069 virtual void connect( Address& a ) throw ( connect_exception ); 00070 00071 protected: 00072 00077 TCP( PRFileDesc* accepted_fd, bool ); 00078 00079 static TCP::pointer create( PRFileDesc* accepted_fd, bool ); 00080 00081 virtual void on_local_address_changed( ); 00082 virtual void on_remote_address_changed( ); 00083 00088 virtual size_t write_data( const Data data, Timeout timeout ) throw ( write_exception ); 00089 00090 }; 00091 00092 } 00093 00094 } 00095 00096 #endif