PTLib  Version 2.10.10
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 ///////////////////////////////////////////////////////////////
Definition: socket.h:86
virtual PObject * Clone() const
Create a copy of the class on the heap.
virtual PBoolean Write(const void *buf, PINDEX len)
Low level write to the channel.
This class describes a type of socket that will communicate using the Internet Protocol.
Definition: ipsock.h:63
WORD port
Port to be used by the socket when opening the channel.
Definition: socket.h:444
BOOL PBoolean
Definition: object.h:102
virtual PBoolean Listen(unsigned queueSize=5, WORD port=0, Reusability reuse=AddressIsExclusive)
Listen on a socket for a remote host on the specified port number.
virtual PBoolean Accept(PSocket &socket)
Open a socket to a remote host on the specified port number.
PTCPSocket(WORD port=0)
Create a TCP/IP protocol socket channel.
The character string class.
Definition: pstring.h:108
A socket that uses the TCP transport on the Internet Protocol.
Definition: tcpsock.h:44
virtual PBoolean OpenSocket()
A class describing an IP address.
Definition: ipsock.h:75
virtual const char * GetProtocolName() const
This function returns the protocol name for the socket type.
A network communications channel.
Definition: socket.h:58
virtual PBoolean WriteOutOfBand(const void *buf, PINDEX len)
Write out of band data from the TCP/IP stream.
Reusability
Flags to reuse of port numbers in Listen() function.
Definition: socket.h:84
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
virtual void OnOutOfBand(const void *buf, PINDEX len)
This is callback function called by the system whenever out of band data from the TCP/IP stream is re...