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 CONEXUS_IPV4TCP_H 00020 #define CONEXUS_IPV4TCP_H 00021 00022 #include <conexus/ipv4_ip.h> 00023 00032 namespace Conexus 00033 { 00034 00035 namespace IPv4 00036 { 00037 00045 class TCP : public IP 00046 { 00047 00048 protected: 00049 00050 friend class TCPServer; 00051 00052 TCP( uint32_t host=INADDR_ANY, uint16_t port=0 ); 00053 00054 TCP( const std::string& host, uint16_t port ); 00055 00056 public: 00057 00058 typedef ConexusPointer<TCP> pointer; 00059 00060 CONEXUS_ENDPOINT_GENERIC_CREATE(); 00061 00062 static pointer create( uint16_t port = 0 ); 00063 00064 static pointer create( uint32_t host, uint16_t port ); 00065 00066 static pointer create( const std::string& host, uint16_t port = 0 ); 00067 00068 virtual ~TCP() throw(); 00069 00076 virtual bool shutdown( ReadWrite read_write=READ_WRITE ); 00077 00078 virtual size_t input_available() throw(); 00079 00083 int pending_output_size(); 00084 00085 protected: 00086 00091 TCP( int accepted_fd, bool ); 00092 00093 static TCP::pointer create( int accepted_fd, bool ); 00094 00095 virtual void on_local_address_changed( ); 00096 virtual void on_remote_address_changed( ); 00097 00102 virtual size_t write_data( const Data data, Timeout timeout ) throw ( write_exception ); 00103 00104 }; 00105 00106 } 00107 00108 } 00109 00110 #endif