00001 /* 00002 * tcpsock.h 00003 * 00004 * Transmission Control Protocol socket channel class. 00005 * 00006 * Portable Windows Library 00007 * 00008 * Copyright (c) 1993-1998 Equivalence Pty. Ltd. 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * The Original Code is Portable Windows Library. 00021 * 00022 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00023 * 00024 * Portions are Copyright (C) 1993 Free Software Foundation, Inc. 00025 * All Rights Reserved. 00026 * 00027 * Contributor(s): ______________________________________. 00028 * 00029 * $Log: tcpsock.h,v $ 00030 * Revision 1.31 2005/11/25 03:43:47 csoutheren 00031 * Fixed function argument comments to be compatible with Doxygen 00032 * 00033 * Revision 1.30 2003/09/17 05:41:59 csoutheren 00034 * Removed recursive includes 00035 * 00036 * Revision 1.29 2003/09/17 01:18:02 csoutheren 00037 * Removed recursive include file system and removed all references 00038 * to deprecated coooperative threading support 00039 * 00040 * Revision 1.28 2002/10/08 12:41:51 robertj 00041 * Changed for IPv6 support, thanks Sébastien Josset. 00042 * 00043 * Revision 1.27 2002/09/16 01:08:59 robertj 00044 * Added #define so can select if #pragma interface/implementation is used on 00045 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00046 * 00047 * Revision 1.26 2001/05/22 12:49:32 robertj 00048 * Did some seriously wierd rewrite of platform headers to eliminate the 00049 * stupid GNU compiler warning about braces not matching. 00050 * 00051 * Revision 1.25 1999/09/28 00:08:59 robertj 00052 * Fixed some comment typoes 00053 * 00054 * Revision 1.24 1999/09/28 00:07:54 robertj 00055 * Fixed some comment typoes 00056 * 00057 * Revision 1.23 1999/08/30 02:21:03 robertj 00058 * Added ability to listen to specific interfaces for IP sockets. 00059 * 00060 * Revision 1.22 1999/03/09 02:59:51 robertj 00061 * Changed comments to doc++ compatible documentation. 00062 * 00063 * Revision 1.21 1999/02/16 08:11:17 robertj 00064 * MSVC 6.0 compatibility changes. 00065 * 00066 * Revision 1.20 1998/12/22 10:23:08 robertj 00067 * Added clone() function to support SOCKS in FTP style protocols. 00068 * 00069 * Revision 1.19 1998/09/23 06:21:37 robertj 00070 * Added open source copyright license. 00071 * 00072 * Revision 1.18 1998/08/21 05:24:46 robertj 00073 * Fixed bug where write streams out to non-stream socket. 00074 * 00075 * Revision 1.17 1996/09/14 13:09:42 robertj 00076 * Major upgrade: 00077 * rearranged sockets to help support IPX. 00078 * added indirect channel class and moved all protocols to descend from it, 00079 * separating the protocol from the low level byte transport. 00080 * 00081 * Revision 1.16 1996/03/26 00:57:15 robertj 00082 * Added contructor that takes PTCPSocket so avoid copy constructor being used instead of accept. 00083 * 00084 * Revision 1.15 1996/03/03 07:37:59 robertj 00085 * Added Reusability clause to the Listen() function on sockets. 00086 * 00087 * Revision 1.14 1996/02/25 03:01:27 robertj 00088 * Moved some socket functions to platform dependent code. 00089 * 00090 * Revision 1.13 1995/12/10 11:43:34 robertj 00091 * Numerous fixes for sockets. 00092 * 00093 * Revision 1.12 1995/06/17 11:13:31 robertj 00094 * Documentation update. 00095 * 00096 * Revision 1.11 1995/06/17 00:47:31 robertj 00097 * Changed overloaded Open() calls to 3 separate function names. 00098 * More logical design of port numbers and service names. 00099 * 00100 * Revision 1.10 1995/06/04 12:46:25 robertj 00101 * Slight redesign of port numbers on sockets. 00102 * 00103 * Revision 1.9 1995/03/14 12:42:46 robertj 00104 * Updated documentation to use HTML codes. 00105 * 00106 * Revision 1.8 1995/03/12 04:46:40 robertj 00107 * Added more functionality. 00108 * 00109 * Revision 1.7 1995/01/03 09:36:22 robertj 00110 * Documentation. 00111 * 00112 * Revision 1.6 1995/01/01 01:07:33 robertj 00113 * More implementation. 00114 * 00115 * Revision 1.5 1994/08/23 11:32:52 robertj 00116 * Oops 00117 * 00118 * Revision 1.4 1994/08/22 00:46:48 robertj 00119 * Added pragma fro GNU C++ compiler. 00120 * 00121 * Revision 1.3 1994/08/21 23:43:02 robertj 00122 * Changed type of socket port number for better portability. 00123 * Added Out of Band data functions. 00124 * 00125 * Revision 1.2 1994/07/25 03:36:03 robertj 00126 * Added sockets to common, normalising to same comment standard. 00127 * 00128 */ 00129 00130 #ifndef _PTCPSOCKET 00131 #define _PTCPSOCKET 00132 00133 #ifdef P_USE_PRAGMA 00134 #pragma interface 00135 #endif 00136 00137 00140 class PTCPSocket : public PIPSocket 00141 { 00142 PCLASSINFO(PTCPSocket, PIPSocket); 00143 public: 00153 PTCPSocket( 00154 WORD port = 0 00155 ); 00156 PTCPSocket( 00157 const PString & service 00158 ); 00159 PTCPSocket( 00160 const PString & address, 00161 WORD port 00162 ); 00163 PTCPSocket( 00164 const PString & address, 00165 const PString & service 00166 ); 00167 PTCPSocket( 00168 PSocket & socket 00169 ); 00170 PTCPSocket( 00171 PTCPSocket & tcpSocket 00172 ); 00174 00189 virtual PObject * Clone() const; 00191 00208 virtual BOOL Write( 00209 const void * buf, 00210 PINDEX len 00211 ); 00213 00229 virtual BOOL Listen( 00230 unsigned queueSize = 5, 00231 WORD port = 0, 00232 Reusability reuse = AddressIsExclusive 00233 ); 00234 virtual BOOL Listen( 00235 const Address & bind, 00236 unsigned queueSize = 5, 00237 WORD port = 0, 00238 Reusability reuse = AddressIsExclusive 00239 ); 00240 00255 virtual BOOL Accept( 00256 PSocket & socket 00257 ); 00259 00273 virtual BOOL WriteOutOfBand( 00274 const void * buf, 00275 PINDEX len 00276 ); 00277 00284 virtual void OnOutOfBand( 00285 const void * buf, 00286 PINDEX len 00287 ); 00289 00290 00291 protected: 00292 // Open an IPv4 socket (for backward compatibility) 00293 virtual BOOL OpenSocket(); 00294 00295 // Open an IPv4 or IPv6 socket 00296 virtual BOOL OpenSocket( 00297 int ipAdressFamily 00298 ); 00299 00300 virtual const char * GetProtocolName() const; 00301 00302 00303 // Include platform dependent part of class 00304 #ifdef _WIN32 00305 #include "msos/ptlib/tcpsock.h" 00306 #else 00307 #include "unix/ptlib/tcpsock.h" 00308 #endif 00309 }; 00310 00311 #endif 00312 00313 // End Of File ///////////////////////////////////////////////////////////////