This class describes a type of socket that will communicate using the Internet Protocol.
More...
Public Member Functions |
|
virtual PBoolean | Connect (const PString &address) |
| Connect a socket to a remote host on the specified port number.
|
virtual PBoolean | Connect (const Address &addr) |
virtual PBoolean | Connect (WORD localPort, const Address &addr) |
virtual PBoolean | Connect (const Address &iface, const Address &addr) |
virtual PBoolean | Connect (const Address &iface, WORD localPort, const Address &addr) |
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 | Listen (const Address &bind, unsigned queueSize=5, WORD port=0, Reusability reuse=AddressIsExclusive) |
PBoolean | Read (void *ptr, PINDEX len) |
| Low level read from the channel.
|
| ~PSocket () |
PBoolean | SetOption (int option, int value, int level=SOL_SOCKET) |
| Set options on the socket.
|
PBoolean | SetOption (int option, const void *valuePtr, PINDEX valueSize, int level=SOL_SOCKET) |
| Set options on the socket.
|
PBoolean | GetOption (int option, int &value, int level=SOL_SOCKET) |
| Get options on the socket.
|
PBoolean | GetOption (int option, void *valuePtr, PINDEX valueSize, int level=SOL_SOCKET) |
| Get options on the socket.
|
virtual PBoolean | Accept (PSocket &socket) |
| Open a socket to a remote host on the specified port number.
|
virtual PBoolean | Shutdown (ShutdownValue option) |
| Close one or both of the data streams associated with a socket.
|
virtual WORD | GetPortByService (const PString &service) const |
| Get the port number for the specified service name.
|
virtual PString | GetServiceByPort (WORD port) const |
| Get the service name from the port number.
|
void | SetPort (WORD port) |
| Set the port number for the channel.
|
void | SetPort (const PString &service) |
| Set the port number for the channel.
|
WORD | GetPort () const |
| Get the port the TCP socket channel object instance is using.
|
PString | GetService () const |
| Get a service name for the port number the TCP socket channel object instance is using.
|
PBoolean | SetErrorValues (Errors errorCode, int osError, ErrorGroup group=LastGeneralError) |
| Set error values to those specified.
|
| PChannel () |
| Create the channel.
|
| ~PChannel () |
| Close down the channel.
|
virtual Comparison | Compare (const PObject &obj) const |
| Get the relative rank of the two strings.
|
virtual PINDEX | HashFunction () const |
| Calculate a hash value for use in sets and dictionaries.
|
virtual PBoolean | IsOpen () const |
| Determine if the channel is currently open.
|
int | GetHandle () const |
| Get the integer operating system handle for the channel.
|
virtual PChannel * | GetBaseReadChannel () const |
| Get the base channel of channel indirection using PIndirectChannel.
|
virtual PChannel * | GetBaseWriteChannel () const |
| Get the base channel of channel indirection using PIndirectChannel.
|
void | SetReadTimeout (const PTimeInterval &time) |
| Set the timeout for read operations.
|
PTimeInterval | GetReadTimeout () const |
| Get the timeout for read operations.
|
virtual PINDEX | GetLastReadCount () const |
| Get the number of bytes read by the last Read() call.
|
virtual int | ReadChar () |
| Read a single 8 bit byte from the channel.
|
PBoolean | ReadBlock (void *buf, PINDEX len) |
| Read len bytes into the buffer from the channel.
|
PString | ReadString (PINDEX len) |
| Read len character into a string from the channel.
|
virtual PBoolean | ReadAsync (void *buf, PINDEX len) |
| Begin an asynchronous read from channel.
|
virtual void | OnReadComplete (void *buf, PINDEX len) |
| User callback function for when a ReadAsync() call has completed or timed out.
|
void | SetWriteTimeout (const PTimeInterval &time) |
| Set the timeout for write operations to complete.
|
PTimeInterval | GetWriteTimeout () const |
| Get the timeout for write operations to complete.
|
virtual PBoolean | Write (const void *buf, PINDEX len) |
| Low level write to the channel.
|
virtual PBoolean | Write (const void *buf, PINDEX len, const void *mark) |
| Low level write to the channel with marker.
|
virtual PINDEX | GetLastWriteCount () const |
| Get the number of bytes written by the last Write() call.
|
PBoolean | WriteChar (int c) |
| Write a single character to the channel.
|
PBoolean | WriteString (const PString &str) |
| Write a string to the channel.
|
virtual PBoolean | WriteAsync (const void *buf, PINDEX len) |
| Begin an asynchronous write from channel.
|
virtual void | OnWriteComplete (const void *buf, PINDEX len) |
| User callback function for when a WriteAsync() call has completed or timed out.
|
virtual PBoolean | Close () |
| Close the channel, shutting down the link to the data source.
|
virtual bool | SetLocalEcho (bool localEcho) |
| Set local echo mode.
|
virtual bool | FlowControl (const void *flowData) |
| Flow Control information Pass data to the channel for flowControl determination.
|
PBoolean | SetBufferSize (PINDEX newSize) |
| Set the iostream buffer size for reads and writes.
|
PBoolean | SendCommandString (const PString &command) |
| Send a command meta-string.
|
void | AbortCommandString () |
| Abort a command string that is in progress.
|
Errors | GetErrorCode (ErrorGroup group=NumErrorGroups) const |
| Get normalised error code.
|
int | GetErrorNumber (ErrorGroup group=NumErrorGroups) const |
| Get OS errro code.
|
virtual PString | GetErrorText (ErrorGroup group=NumErrorGroups) const |
| Get error message description.
|
virtual PBoolean | Read (const VectorOfSlice &slices) |
| Low level scattered read from the channel.
|
virtual PBoolean | Write (const VectorOfSlice &slices) |
| Low level scattered write to the channel.
|
virtual | ~PObject () |
virtual PObject * | Clone () const |
| Create a copy of the class on the heap.
|
virtual Comparison | CompareObjectMemoryDirect (const PObject &obj) const |
| Determine the byte wise comparison of two objects.
|
bool | operator== (const PObject &obj) const |
| Compare the two objects.
|
bool | operator!= (const PObject &obj) const |
| Compare the two objects.
|
bool | operator< (const PObject &obj) const |
| Compare the two objects.
|
bool | operator> (const PObject &obj) const |
| Compare the two objects.
|
bool | operator<= (const PObject &obj) const |
| Compare the two objects.
|
bool | operator>= (const PObject &obj) const |
| Compare the two objects.
|
virtual const char * | GetClass (unsigned ancestor=0) const |
| Get the current dynamic type of the object instance.
|
PBoolean | IsClass (const char *cls) const |
virtual PBoolean | InternalIsDescendant (const char *clsName) const |
| Determine if the dynamic type of the current instance is a descendent of the specified class.
|
virtual void | PrintOn (ostream &strm) const |
| Output the contents of the object to the stream.
|
virtual void | ReadFrom (istream &strm) |
| Input the contents of the object from the stream.
|
Protected Member Functions |
| PIPSocket () |
| Create a new Internet Protocol socket based on the port number specified.
|
| PSocket () |
virtual PBoolean | OpenSocket ()=0 |
virtual const char * | GetProtocolName () const =0 |
| This function returns the protocol name for the socket type.
|
int | os_close () |
int | os_socket (int af, int type, int proto) |
PBoolean | os_connect (struct sockaddr *sin, PINDEX size) |
PBoolean | os_recvfrom (void *buf, PINDEX len, int flags, struct sockaddr *from, PINDEX *fromlen) |
PBoolean | os_sendto (const void *buf, PINDEX len, int flags, struct sockaddr *to, PINDEX tolen) |
PBoolean | os_accept (PSocket &listener, struct sockaddr *addr, PINDEX *size) |
| PChannel (const PChannel &) |
PChannel & | operator= (const PChannel &) |
virtual PBoolean | ConvertOSError (int libcReturnValue, ErrorGroup group=LastGeneralError) |
| Convert an operating system error into platform independent error.
|
int | ReadCharWithTimeout (PTimeInterval &timeout) |
| Read a character with specified timeout.
|
PBoolean | ReceiveCommandString (int nextChar, const PString &reply, PINDEX &pos, PINDEX start) |
PBoolean | PXSetIOBlock (PXBlockType type, const PTimeInterval &timeout) |
int | PXClose () |
| PObject () |
| Constructor for PObject, made protected so cannot ever create one on its own.
|
virtual PString | GetName () const |
| Get the platform and I/O channel type name of the channel.
|
virtual PBoolean | OpenSocket (int ipAdressFamily=PF_INET)=0 |
| Open an IPv4 or IPv6 socket.
|
static int | GetDefaultIpAddressFamily () |
| Set the default IP address familly.
|
static void | SetDefaultIpAddressFamily (int ipAdressFamily) |
static void | SetDefaultIpAddressFamilyV4 () |
static PIPSocket::Address | GetDefaultIpAny () |
New functions for class |
virtual PString | GetLocalAddress () |
| Get the Internet Protocol address and port for the local host.
|
virtual PBoolean | GetLocalAddress (Address &addr) |
virtual PBoolean | GetLocalAddress (PIPSocketAddressAndPort &addr) |
virtual PBoolean | GetLocalAddress (Address &addr, WORD &port) |
virtual PString | GetPeerAddress () |
| Get the Internet Protocol address for the peer host and port the socket is connected to.
|
virtual PBoolean | GetPeerAddress (Address &addr) |
virtual PBoolean | GetPeerAddress (PIPSocketAddressAndPort &addr) |
virtual PBoolean | GetPeerAddress (Address &addr, WORD &port) |
PString | GetLocalHostName () |
| Get the host name for the local host.
|
PString | GetPeerHostName () |
| Get the host name for the peer host the socket is connected to.
|
| PARRAY (RouteTable, RouteEntry) |
| PARRAY (InterfaceTable, InterfaceEntry) |
PBoolean | SetCaptureReceiveToAddress () |
| Set flag to capture interface address for incoming packets.
|
PIPSocket::Address | GetLastReceiveToAddress () const |
| Return the interface address of the last incoming packet.
|
static PString | GetHostName () |
| Get the "official" host name for the host specified or if none, the host this process is running on.
|
static PString | GetHostName (const PString &hostname) |
static PString | GetHostName (const Address &addr) |
static PBoolean | GetHostAddress (Address &addr) |
| Get the Internet Protocol address for the specified host, or if none specified, for the host this process is running on.
|
static PBoolean | GetHostAddress (const PString &hostname, Address &addr) |
static PStringArray | GetHostAliases (const PString &hostname) |
| Get the alias host names for the specified host.
|
static PStringArray | GetHostAliases (const Address &addr) |
static PBoolean | IsLocalHost (const PString &hostname) |
| Determine if the specified host is actually the local machine.
|
static void | ClearNameCache () |
| Clear the name (DNS) cache.
|
static PBoolean | GetGatewayAddress (Address &addr, int version=4) |
| Get the IP address that is being used as the gateway, that is, the computer that packets on the default route will be sent.
|
static PString | GetGatewayInterface (int version=4) |
| 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.
|
static PIPSocket::Address | GetRouteInterfaceAddress (PIPSocket::Address remoteAddress) |
| Get the interface address that will be used to reach the specified remote address.
|
static PBoolean | GetRouteTable (RouteTable &table) |
| Get the systems route table.
|
static RouteTableDetector * | CreateRouteTableDetector () |
| Create an object that can wait for a change in the route table or active network interfaces.
|
static PBoolean | GetInterfaceTable (InterfaceTable &table, PBoolean includeDown=false) |
| Get a list of all interfaces.
|
static PBoolean | GetNetworkInterface (PIPSocket::Address &addr) |
| Get the address of an interface that corresponds to a real network.
|
Additional Inherited Members |
enum | Reusability { CanReuseAddress,
AddressIsExclusive
} |
| Flags to reuse of port numbers in Listen() function. More...
|
enum | PXBlockType { PXReadBlock,
PXWriteBlock,
PXAcceptBlock,
PXConnectBlock
} |
enum | ShutdownValue { ShutdownRead = 0,
ShutdownWrite = 1,
ShutdownReadAndWrite = 2
} |
enum | Errors {
NoError,
NotFound,
FileExists,
DiskFull,
AccessDenied,
DeviceInUse,
BadParameter,
NoMemory,
NotOpen,
Timeout,
Interrupted,
BufferTooSmall,
Miscellaneous,
ProtocolFailure,
NumNormalisedErrors
} |
| Normalised error codes. More...
|
enum | ErrorGroup { LastReadError,
LastWriteError,
LastGeneralError,
NumErrorGroups
} |
| Error groups. More...
|
typedef std::vector< Slice > | VectorOfSlice |
static int | Select (PSocket &sock1, PSocket &sock2) |
| Select a socket with available data.
|
static int | Select (PSocket &sock1, PSocket &sock2, const PTimeInterval &timeout) |
| Select a socket with available data.
|
static Errors | Select (SelectList &read) |
| Select a socket with available data.
|
static Errors | Select (SelectList &read, const PTimeInterval &timeout) |
| Select a socket with available data.
|
static Errors | Select (SelectList &read, SelectList &write) |
| Select a socket with available data.
|
static Errors | Select (SelectList &read, SelectList &write, const PTimeInterval &timeout) |
| Select a socket with available data.
|
static Errors | Select (SelectList &read, SelectList &write, SelectList &except) |
| Select a socket with available data.
|
static Errors | Select (SelectList &read, SelectList &write, SelectList &except, const PTimeInterval &timeout) |
| Select a socket with available data.
|
static WORD | Host2Net (WORD v) |
| Convert from host to network byte order.
|
static DWORD | Host2Net (DWORD v) |
| Convert from host to network byte order.
|
static WORD | Net2Host (WORD v) |
| Convert from network to host byte order.
|
static DWORD | Net2Host (DWORD v) |
| Convert from network to host byte order.
|
static WORD | GetProtocolByName (const PString &name) |
| Get the number of the protocol associated with the specified name.
|
static PString | GetNameByProtocol (WORD proto) |
| Get the name of the protocol number specified.
|
static WORD | GetPortByService (const char *protocol, const PString &service) |
| Get the port number for the specified service name.
|
static PString | GetServiceByPort (const char *protocol, WORD port) |
| Get the service name from the port number.
|
WORD | port |
| Port to be used by the socket when opening the channel.
|
This class describes a type of socket that will communicate using the Internet Protocol.
If P_HAS_IPV6 is not set, IPv4 only is supported. If P_HAS_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.