class PIPSocket

This class describes a type of socket that will communicate using the Internet Protocol.

Inheritance:


Public Methods

[more]virtual PString GetName () const
Get the platform and I/O channel type name of the channel.
[more]virtual BOOL Connect ( const PString & address )
Connect a socket to a remote host on the specified port number.
[more]virtual BOOL Listen ( unsigned queueSize = 5, WORD port = 0, Reusability reuse = AddressIsExclusive )
Listen on a socket for a remote host on the specified port number.
[more]static PString GetHostName ()
Get the "official" host name for the host specified or if none, the host this process is running on.
[more]static BOOL GetHostAddress ( Address & addr )
Get the Internet Protocol address for the specified host, or if none specified, for the host this process is running on.
[more]static PStringArray GetHostAliases ( const PString & hostname )
Get the alias host names for the specified host.
[more]static BOOL IsLocalHost ( const PString & hostname )
Determine if the specified host is actually the local machine.
[more]virtual BOOL GetLocalAddress ( Address & addr )
Get the Internet Protocol address for the local host.
[more]virtual BOOL GetPeerAddress ( Address & addr )
Get the Internet Protocol address for the peer host the socket is connected to.
[more]PString GetLocalHostName ()
Get the host name for the local host.
[more]PString GetPeerHostName ()
Get the host name for the peer host the socket is connected to.
[more]static void ClearNameCache ()
Clear the name (DNS) cache
[more]static BOOL GetGatewayAddress ( Address & addr )
Get the IP address that is being used as the gateway, that is, the computer that packets on the default route will be sent.
[more]static PString GetGatewayInterface ()
Get the name for the interface that is being used as the gateway, that is, the interface that packets on the default route will be sent.
[more]static BOOL GetRouteTable ( RouteTable & table )
Get the systems route table.
[more]static BOOL GetInterfaceTable ( InterfaceTable & table )
Get a list of all interfaces

Public Members

class Address
A class describing an IP address
class RouteEntry
Describes a route table entry
class InterfaceEntry
Describes an interface table entry


Inherited from PSocket:

Public Methods

Socket establishment functions

Socket options functions

Port/Service database functions

Integer conversion functions

Public Members

Multiple socket selection functions

Protected Fields

oWORD port

Protected Methods

ovirtual const char* GetProtocolName() const


Inherited from PChannel:

Public Methods

Construction

Overrides from class PObject

Information functions

Reading functions

Writing functions

Miscellaneous functions

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

Public Members

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 Methods

Run Time Type functions

I/O functions

Public Members

Comparison functions


Documentation

This class describes a type of socket that will communicate using the Internet Protocol. If P_USE_IPV6 is not set, IPv4 only is supported. If P_USE_IPV6 is set, both IPv4 and IPv6 adresses are supported, with IPv4 as default. This allows to transparently use IPv4, IPv6 or Dual stack operating systems.
ovirtual PString GetName() const
Get the platform and I/O channel type name of the channel. For an IP socket this returns the host name of the peer the socket is connected to, followed by the socket number it is connected to.

Returns:
the name of the channel.

ovirtual BOOL Connect( const PString & address )
Connect a socket to a remote host on the specified port number. This is typically used by the client or initiator of a communications channel. This connects to a "listening" socket at the other end of the communications channel.

The port number as defined by the object instance construction or the PIPSocket::SetPort() function.

Parameters:
address - Address of remote machine to connect to.
Returns:
TRUE if the channel was successfully connected to the remote host.

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 "accepting" 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.

For the UDP protocol, the queueSize parameter is ignored.

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

ostatic PString GetHostName()
Get the "official" host name for the host specified or if none, the host this process is running on. The host may be specified as an IP number or a hostname alias and is resolved to the canonical form.

Returns:
Name of the host or IP number of host.

ostatic BOOL GetHostAddress( Address & addr )
Get the Internet Protocol address for the specified host, or if none specified, for the host this process is running on.

Parameters:
- addr Variable to receive hosts IP address
Returns:
TRUE if the IP number was returned.

ostatic PStringArray GetHostAliases( const PString & hostname )
Get the alias host names for the specified host. This includes all DNS names, CNAMEs, names in the local hosts file and IP numbers (as "dot" format strings) for the host.

Returns:
array of strings for each alias for the host.

ostatic BOOL IsLocalHost( const PString & hostname )
Determine if the specified host is actually the local machine. This can be any of the host aliases or multi-homed IP numbers or even the special number 127.0.0.1 for the loopback device.

Returns:
TRUE if the host is the local machine.

ovirtual BOOL GetLocalAddress( Address & addr )
Get the Internet Protocol address for the local host.

Parameters:
- addr Variable to receive hosts IP address
Returns:
TRUE if the IP number was returned.

ovirtual BOOL GetPeerAddress( Address & addr )
Get the Internet Protocol address for the peer host the socket is connected to.

Parameters:
- addr Variable to receive hosts IP address
Returns:
TRUE if the IP number was returned.

oPString GetLocalHostName()
Get the host name for the local host.

Returns:
Name of the host, or an empty string if an error occurs.

oPString GetPeerHostName()
Get the host name for the peer host the socket is connected to.

Returns:
Name of the host, or an empty string if an error occurs.

ostatic void ClearNameCache()
Clear the name (DNS) cache

ostatic BOOL GetGatewayAddress( Address & addr )
Get the IP address that is being used as the gateway, that is, the computer that packets on the default route will be sent.

The string returned may be used in the Connect() function to open that interface.

Note that the driver does not need to be open for this function to work.

Parameters:
- addr Variable to receive the IP address.
Returns:
TRUE if there was a gateway.

ostatic PString GetGatewayInterface()
Get the name for the interface that is being used as the gateway, that is, the interface that packets on the default route will be sent.

The string returned may be used in the Connect() function to open that interface.

Note that the driver does not need to be open for this function to work.

Returns:
String name of the gateway device, or empty string if there is none.

ostatic BOOL GetRouteTable( RouteTable & table )
Get the systems route table.

Parameters:
table - Route table
Returns:
TRUE if the route table is returned, FALSE if an error occurs.

ostatic BOOL GetInterfaceTable( InterfaceTable & table )
Get a list of all interfaces

Parameters:
table - interface table
Returns:
TRUE if the interface table is returned, FALSE if an error occurs.


Direct child classes:
PTCPSocket
PIPDatagramSocket

Alphabetic index HTML hierarchy of classes or Java



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