PTLib  Version 2.10.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tcpsock.h
Go to the documentation of this file.
1 /*
2  * tcpsock.h
3  *
4  * Transmission Control Protocol socket channel class.
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25  * All Rights Reserved.
26  *
27  * Contributor(s): ______________________________________.
28  *
29  * $Revision: 24177 $
30  * $Author: rjongbloed $
31  * $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
32  */
33 
34 #ifndef PTLIB_TCPSOCKET_H
35 #define PTLIB_TCPSOCKET_H
36 
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40 
41 
44 class PTCPSocket : public PIPSocket
45 {
46  PCLASSINFO(PTCPSocket, PIPSocket);
47  public:
57  PTCPSocket(
58  WORD port = 0
59  );
60  PTCPSocket(
61  const PString & service
62  );
63  PTCPSocket(
64  const PString & address,
65  WORD port
66  );
67  PTCPSocket(
68  const PString & address,
69  const PString & service
70  );
71  PTCPSocket(
72  PSocket & socket
73  );
74  PTCPSocket(
75  PTCPSocket & tcpSocket
76  );
78 
93  virtual PObject * Clone() const;
95 
112  virtual PBoolean Write(
113  const void * buf,
114  PINDEX len
115  );
117 
140  virtual PBoolean Listen(
141  unsigned queueSize = 5,
142  WORD port = 0,
144  );
145  virtual PBoolean Listen(
146  const Address & bind,
147  unsigned queueSize = 5,
148  WORD port = 0,
150  );
151 
166  virtual PBoolean Accept(
167  PSocket & socket
168  );
170 
184  virtual PBoolean WriteOutOfBand(
185  const void * buf,
186  PINDEX len
187  );
188 
195  virtual void OnOutOfBand(
196  const void * buf,
197  PINDEX len
198  );
200 
201 
202  protected:
203  // Open an IPv4 socket (for backward compatibility)
204  virtual PBoolean OpenSocket();
205 
206  // Open an IPv4 or IPv6 socket
207  virtual PBoolean OpenSocket(
208  int ipAdressFamily
209  );
210 
211  virtual const char * GetProtocolName() const;
212 
213 
214 // Include platform dependent part of class
215 #ifdef _WIN32
216 #include "msos/ptlib/tcpsock.h"
217 #else
218 #include "unix/ptlib/tcpsock.h"
219 #endif
220 };
221 
222 #endif // PTLIB_TCPSOCKET_H
223 
224 
225 // End Of File ///////////////////////////////////////////////////////////////