class PTCPSocket: public PIPSocket

A socket that uses the TCP transport on the Internet Protocol

Inheritance:


Public

[more] Construction.
[more] Overrides from class PObject.
[more] Overrides from class PChannel.
[more] Overrides from class PSocket.
[more] New functions for class.


Inherited from PIPSocket:

Public Classes

oclass Address: public in_addr
oclass RouteEntry: public PObject
oclass InterfaceEntry: public PObject

Public Methods

ovirtual PString GetName() const
ovirtual BOOL Connect( const PString & address )
ovirtual BOOL Listen( unsigned queueSize = 5, WORD port = 0, Reusability reuse = AddressIsExclusive )
ostatic PString GetHostName()
ostatic BOOL GetHostAddress( Address & addr )
ostatic PStringArray GetHostAliases( const PString & hostname )
ostatic BOOL IsLocalHost( const PString & hostname )
ovirtual BOOL GetLocalAddress( Address & addr )
ovirtual BOOL GetPeerAddress( Address & addr )
oPString GetLocalHostName()
oPString GetPeerHostName()
ostatic void ClearNameCache()
ostatic BOOL GetGatewayAddress( Address & addr )
ostatic PString GetGatewayInterface()
ostatic BOOL GetRouteTable( RouteTable & table )
ostatic BOOL GetInterfaceTable( InterfaceTable & table )


Inherited from PSocket:

Public

Socket establishment functions

Socket options functions

Port/Service database functions

Multiple socket selection functions

Integer conversion functions

Protected Fields

oWORD port

Protected Methods

ovirtual const char* GetProtocolName() const


Inherited from PChannel:

Public Methods

ostatic BOOL ConvertOSError( int libcReturnValue, Errors & lastError, int & osError )

Public

Construction

Overrides from class PObject

Information functions

Reading functions

Writing functions

Miscellaneous functions

Error functions

Protected Fields

oint os_handle
oErrors lastErrorCode[NumErrorGroups+1]
oint lastErrorNumber[NumErrorGroups+1]
oPINDEX lastReadCount
oPINDEX lastWriteCount
oPTimeInterval readTimeout
oPTimeInterval writeTimeout

Protected Methods

ovirtual BOOL ConvertOSError( int libcReturnValue, ErrorGroup group = LastGeneralError )
oBOOL SetErrorValues( Errors errorCode, int osError, ErrorGroup group = LastGeneralError )
oint ReadCharWithTimeout( PTimeInterval & timeout )


Inherited from PObject:

Public

Run Time Type functions

Comparison functions

I/O functions


Documentation

A socket that uses the TCP transport on the Internet Protocol
o Construction.

o PTCPSocket( WORD port = 0 )
Create a TCP/IP protocol socket channel. If a remote machine address or a "listening" socket is specified then the channel is also opened.

Note that what looks like a "copy" constructor here is really a the accept of a "listening" socket the same as the PSocket & parameter version constructor.

Parameters:
port - Port number to use for the connection.

o Overrides from class PObject.

ovirtual PObject* Clone() const
Create a copy of the class on the heap. The exact semantics of the descendent class determine what is required to make a duplicate of the instance. Not all classes can even do a clone operation.

The main user of the clone function is the PDictionary class as it requires copies of the dictionary keys.

The default behaviour is for this function to assert.

Returns:
pointer to new copy of the class instance.

o Overrides from class PChannel.

ovirtual BOOL Write( const void * buf, PINDEX len )
Low level write to the channel. This function will block until the requested number of characters are written or the write timeout is reached. The GetLastWriteCount() function returns the actual number of bytes written.

The GetErrorCode() function should be consulted after Write() returns FALSE to determine what caused the failure.

This override repeatedly writes if there is no error until all of the requested bytes have been written.

Returns:
TRUE if at least len bytes were written to the channel.
Parameters:
buf - Pointer to a block of memory to write.
len - Number of bytes to write.

o Overrides from class PSocket.

ovirtual BOOL Listen( unsigned queueSize = 5, WORD port = 0, Reusability reuse = AddressIsExclusive )
Listen on a socket for a remote host on the specified port number. This may be used for server based applications. A "connecting" socket begins a connection by initiating a connection to this socket. An active socket of this type is then used to generate other äccepting" sockets which establish a two way communications channel with the "connecting" socket.

If the port parameter is zero then the port number as defined by the object instance construction or the PIPSocket::SetPort() function.

Returns:
TRUE if the channel was successfully opened.
Parameters:
queueSize - Number of pending accepts that may be queued.
port - Port number to use for the connection.
reuse - Can/Can't listen more than once.

ovirtual BOOL Accept( PSocket & socket )
Open a socket to a remote host on the specified port number. This is an äccepting" socket. When a "listening" socket has a pending connection to make, this will accept a connection made by the "connecting" socket created to establish a link.

The port that the socket uses is the one used in the Listen() command of the socket parameter.

Note that this function will block until a remote system connects to the port number specified in the "listening" socket.

Returns:
TRUE if the channel was successfully opened.
Parameters:
socket - Listening socket making the connection.

o New functions for class.

ovirtual BOOL WriteOutOfBand( const void * buf, PINDEX len )
Write out of band data from the TCP/IP stream. This data is sent as TCP URGENT data which does not follow the usual stream sequencing of the normal channel data.

This is subject to the write timeout and sets the lastWriteCount member variable in the same way as usual PChannel::Write() function.

Returns:
TRUE if all the bytes were sucessfully written.
Parameters:
buf - Data to be written as URGENT TCP data.
len - Number of bytes pointed to by buf.

ovirtual 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 received. A descendent class may interpret this data according to the semantics of the high level protocol.

The default behaviour is for the out of band data to be ignored.

Parameters:
buf - Data to be received as URGENT TCP data.
len - Number of bytes pointed to by buf.


Direct child classes:
PTelnetSocket
PSocksSocket

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.