PTLib
Version 2.18.8
|
Create a socket channel that uses allows ICMP commands in the Internal Protocol. More...
#include <icmpsock.h>
Classes | |
class | PingInfo |
Information used by and obtained by the ping operation. More... | |
Public Member Functions | |
Construction | |
PICMPSocket () | |
Create a TCP/IP protocol socket channel. More... | |
Ping | |
PBoolean | Ping (const PString &host) |
Send an ECHO_REPLY message to the specified host and wait for a reply to be sent back. More... | |
PBoolean | Ping (const PString &host, PingInfo &info) |
Send an ECHO_REPLY message to the specified host and wait for a reply to be sent back. More... | |
![]() | |
virtual PBoolean | ReadFrom (void *buf, PINDEX len, Address &addr, WORD &port) |
Read a datagram from a remote computer. More... | |
virtual PBoolean | ReadFrom (void *buf, PINDEX len, PIPSocketAddressAndPort &ipAndPort) |
virtual PBoolean | ReadFrom (Slice *slices, size_t sliceCount, Address &addr, WORD &port) |
virtual PBoolean | ReadFrom (Slice *slices, size_t sliceCount, PIPSocketAddressAndPort &ipAndPort) |
virtual PBoolean | WriteTo (const void *buf, PINDEX len, const Address &addr, WORD port) |
Write a datagram to a remote computer. More... | |
virtual PBoolean | WriteTo (const void *buf, PINDEX len, const PIPSocketAddressAndPort &ipAndPort) |
virtual PBoolean | WriteTo (const Slice *slices, size_t sliceCount, const Address &addr, WORD port) |
virtual PBoolean | WriteTo (const Slice *slices, size_t sliceCount, const PIPSocketAddressAndPort &ipAndPort) |
virtual bool | InternalReadFrom (Slice *slices, size_t sliceCount, PIPSocketAddressAndPort &ipAndPort) |
virtual bool | InternalWriteTo (const Slice *slices, size_t sliceCount, const PIPSocketAddressAndPort &ipAndPort) |
![]() | |
virtual bool | InternalGetLocalAddress (AddressAndPort &addrAndPort) |
virtual bool | InternalGetPeerAddress (AddressAndPort &addrAndPort) |
virtual bool | InternalListen (const Address &bind, unsigned queueSize, WORD port, Reusability reuse) |
virtual void | PrintOn (ostream &strm) const |
Output the contents of the URL to the stream as a string. More... | |
virtual PBoolean | Connect (const PString &address) |
Connect a socket to a remote host on the specified port number. More... | |
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. More... | |
virtual PBoolean | Listen (const Address &bind, unsigned queueSize=5, WORD port=0, Reusability reuse=AddressIsExclusive) |
virtual bool | SetQoS (const QoS &qos) |
Set the current Quality of Service. More... | |
const QoS & | GetQoS () const |
Get the current Quality of Service. More... | |
virtual PString | GetName () const |
Get the platform and I/O channel type name of the channel. More... | |
PString | GetLocalAddress () const |
Get the Internet Protocol address and port for the local host. More... | |
bool | GetLocalAddress (Address &addr) const |
bool | GetLocalAddress (Address &addr, WORD &port) const |
bool | GetLocalAddress (AddressAndPort &addr) const |
PString | GetPeerAddress () const |
Get the Internet Protocol address for the peer host and port the socket is connected to. More... | |
bool | GetPeerAddress (Address &addr) const |
bool | GetPeerAddress (Address &addr, WORD &port) const |
bool | GetPeerAddress (AddressAndPort &addr) const |
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... | |
PARRAY (RouteTable, RouteEntry) | |
PARRAY (InterfaceTable, InterfaceEntry) | |
P_DECLARE_ENUM (QoSType, BackgroundQoS, BestEffortQoS, ExcellentEffortQoS, CriticalQoS, VideoQoS, VoiceQoS, ControlQoS) | |
The types of QoS supported, based on IEEE P802.1p TrafficClass parameter. More... | |
![]() | |
virtual bool | Read (void *ptr, PINDEX len) |
Low level read from the channel. More... | |
virtual bool | Write (const void *buf, PINDEX len) |
Low level write to the channel. More... | |
~PSocket () | |
PBoolean | SetOption (int option, int value, int level=SOL_SOCKET) |
Set options on the socket. More... | |
PBoolean | SetOption (int option, const void *valuePtr, PINDEX valueSize, int level=SOL_SOCKET) |
Set options on the socket. More... | |
PBoolean | GetOption (int option, int &value, int level=SOL_SOCKET) |
Get options on the socket. More... | |
PBoolean | GetOption (int option, void *valuePtr, PINDEX valueSize, int level=SOL_SOCKET) |
Get options on the socket. More... | |
virtual bool | Read (Slice *slices, size_t sliceCount) |
Low level scattered read from the channel. More... | |
virtual bool | Write (const Slice *slices, size_t sliceCount) |
Low level scattered write to the channel. More... | |
virtual PBoolean | Accept (PSocket &socket) |
Open a socket to a remote host on the specified port number. More... | |
virtual PBoolean | Shutdown (ShutdownValue option) |
Close one or both of the data streams associated with a socket. More... | |
virtual WORD | GetPortByService (const PString &service) const |
Get the port number for the specified service name. More... | |
virtual PString | GetServiceByPort (WORD port) const |
Get the service name from the port number. More... | |
void | SetPort (WORD port) |
Set the port number for the channel. More... | |
void | SetPort (const PString &service) |
Set the port number for the channel. More... | |
WORD | GetPort () const |
Get the port the TCP socket channel object instance is using. More... | |
PString | GetService () const |
Get a service name for the port number the TCP socket channel object instance is using. More... | |
![]() | |
PBoolean | SetErrorValues (Errors errorCode, int osError, ErrorGroup group=LastGeneralError) |
Set error values to those specified. More... | |
virtual Comparison | Compare (const PObject &obj) const |
Get the relative rank of the two strings. More... | |
virtual PINDEX | HashFunction () const |
Calculate a hash value for use in sets and dictionaries. More... | |
virtual PBoolean | IsOpen () const |
Determine if the channel is currently open. More... | |
virtual P_INT_PTR | GetHandle () const |
Get the integer operating system handle for the channel. More... | |
FILE * | FDOpen (const char *mode) |
Re-open the device using the stdio library. More... | |
virtual PChannel * | GetBaseReadChannel () const |
Get the base channel of channel indirection using PIndirectChannel. More... | |
virtual PChannel * | GetBaseWriteChannel () const |
Get the base channel of channel indirection using PIndirectChannel. More... | |
virtual bool | CloseBaseReadChannel () |
Close the base channel of channel indirection using PIndirectChannel. More... | |
virtual bool | CloseBaseWriteChannel () |
Close the base channel of channel indirection using PIndirectChannel. More... | |
void | SetReadTimeout (const PTimeInterval &time) |
Set the timeout for read operations. More... | |
PTimeInterval | GetReadTimeout () const |
Get the timeout for read operations. More... | |
virtual PINDEX | GetLastReadCount () const |
Get the number of bytes read by the last Read() call. More... | |
virtual PINDEX | SetLastReadCount (PINDEX count) |
virtual int | ReadChar () |
Read a single character from the channel. More... | |
PBoolean | ReadBlock (void *buf, PINDEX len) |
Read len bytes into the buffer from the channel. More... | |
PString | ReadString (PINDEX len) |
Read len character into a string from the channel. More... | |
void | SetWriteTimeout (const PTimeInterval &time) |
Set the timeout for write operations to complete. More... | |
PTimeInterval | GetWriteTimeout () const |
Get the timeout for write operations to complete. More... | |
virtual PBoolean | Write (const void *buf, PINDEX len, const void *) |
Low level write to the channel with marker. More... | |
virtual PINDEX | GetLastWriteCount () const |
Get the number of bytes written by the last Write() call. More... | |
virtual PINDEX | SetLastWriteCount (PINDEX count) |
PBoolean | WriteChar (int c) |
Write a single character to the channel. More... | |
PBoolean | WriteString (const PString &str) |
Write a string to the channel. More... | |
~PChannel () | |
Close down the channel. More... | |
Errors | GetErrorCode (ErrorGroup group=NumErrorGroups) const |
Get normalised error code. More... | |
int | GetErrorNumber (ErrorGroup group=NumErrorGroups) const |
Get OS errro code. More... | |
virtual PString | GetErrorText (ErrorGroup group=NumErrorGroups) const |
Get error message description. More... | |
virtual bool | ReadAsync (AsyncContext &context) |
Begin an asynchronous read from channel. More... | |
virtual void | OnReadComplete (AsyncContext &context) |
User callback function for when a ReadAsync() call has completed or timed out. More... | |
virtual bool | WriteAsync (AsyncContext &context) |
Begin an asynchronous write from channel. More... | |
virtual void | OnWriteComplete (AsyncContext &context) |
User callback function for when a WriteAsync() call has completed or timed out. More... | |
virtual PBoolean | Close () |
Close the channel, shutting down the link to the data source. More... | |
virtual bool | SetLocalEcho (bool localEcho) |
Set local echo mode. More... | |
virtual bool | FlowControl (const void *flowData) |
Flow Control information Pass data to the channel for flowControl determination. More... | |
PBoolean | SetBufferSize (PINDEX newSize) |
Set the iostream buffer size for reads and writes. More... | |
PBoolean | SendCommandString (const PString &command) |
Send a command meta-string. More... | |
void | AbortCommandString () |
Abort a command string that is in progress. More... | |
![]() | |
__inline unsigned | GetTraceContextIdentifier () const |
Get PTRACE context identifier. More... | |
__inline void | SetTraceContextIdentifier (unsigned id) |
__inline void | SetTraceContextIdentifier (const PObject &obj) |
__inline void | SetTraceContextIdentifier (const PObject *obj) |
__inline void | CopyTraceContextIdentifier (PObject &obj) const |
__inline void | CopyTraceContextIdentifier (PObject *obj) const |
virtual | ~PObject () |
__inline const char * | GetClass () const |
__inline bool | IsClass (const char *name) const |
__inline const PObject * | PTraceObjectInstance () const |
virtual PObject * | Clone () const |
Create a copy of the class on the heap. More... | |
template<class CLS > | |
CLS * | CloneAs () const |
As for Clone() but converts to specified type. More... | |
virtual Comparison | CompareObjectMemoryDirect (const PObject &obj) const |
Determine the byte wise comparison of two objects. More... | |
bool | operator== (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator!= (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator< (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator> (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator<= (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator>= (const PObject &obj) const |
Compare the two objects. More... | |
virtual void | ReadFrom (istream &strm) |
Input the contents of the object from the stream. More... | |
Protected Member Functions | |
const char * | GetProtocolName () const |
This function returns the protocol name for the socket type. More... | |
virtual PBoolean | OpenSocket () |
virtual PBoolean | OpenSocket (int ipAdressFamily) |
Open an IPv4 or IPv6 socket. More... | |
PBoolean | WritePing (const PString &host, PingInfo &info) |
PBoolean | ReadPing (PingInfo &info) |
![]() | |
PIPDatagramSocket () | |
Create a TCP/IP protocol socket channel. More... | |
![]() | |
PIPSocket () | |
Create a new Internet Protocol socket based on the port number specified. More... | |
![]() | |
PSocket () | |
virtual PBoolean | ConvertOSError (P_INT_PTR libcReturnValue, ErrorGroup group=LastGeneralError) |
Convert an operating system error into platform independent error. More... | |
int | os_close () |
int | os_socket (int af, int type, int proto) |
PBoolean | os_connect (struct sockaddr *sin, socklen_t size) |
PBoolean | os_vread (Slice *slices, size_t sliceCount, int flags, struct sockaddr *from, socklen_t *fromlen) |
PBoolean | os_vwrite (const Slice *slices, size_t sliceCount, int flags, struct sockaddr *to, socklen_t tolen) |
PBoolean | os_accept (PSocket &listener, struct sockaddr *addr, socklen_t *size) |
virtual int | os_errno () const |
![]() | |
PChannel (const PChannel &) | |
PChannel & | operator= (const PChannel &) |
int | ReadCharWithTimeout (PTimeInterval &timeout) |
Read a character with specified timeout. More... | |
PBoolean | ReceiveCommandString (int nextChar, const PString &reply, PINDEX &pos, PINDEX start) |
bool | CheckNotOpen () |
PBoolean | PXSetIOBlock (PXBlockType type, const PTimeInterval &timeout) |
P_INT_PTR | GetOSHandleAsInt () const |
int | PXClose () |
PDECLARE_MUTEX (px_threadMutex) | |
PDECLARE_MUTEX (px_writeMutex) | |
PChannel () | |
Create the channel. More... | |
![]() | |
PObject () | |
Constructor for PObject, made protected so cannot ever create one on its own. More... | |
Additional Inherited Members | |
![]() | |
static int | GetDefaultIpAddressFamily () |
Set the default IP address familly. More... | |
static void | SetDefaultIpAddressFamily (int ipAdressFamily) |
static void | SetDefaultIpAddressFamilyV4 () |
static const PIPSocket::Address & | GetDefaultIpAny () |
static const PIPSocket::Address & | GetInvalidAddress () |
static void | SetSuppressCanonicalName (bool suppress) |
Set flag for suppress getting canonical name when doing lookup via hostname. More... | |
static bool | GetSuppressCanonicalName () |
Get flag for suppress getting canonical name when doing lookup via hostname. 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 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. More... | |
static PBoolean | GetHostAddress (const PString &hostname, Address &addr) |
static PStringArray | GetHostAliases (const PString &hostname) |
Get the alias host names for the specified host. More... | |
static PStringArray | GetHostAliases (const Address &addr) |
static PBoolean | IsLocalHost (const PString &hostname) |
Determine if the specified host is actually the local machine. More... | |
static void | ClearNameCache () |
Clear the name (DNS) cache. More... | |
static PBoolean | GetRouteTable (RouteTable &table) |
Get the systems route table. More... | |
static RouteTableDetector * | CreateRouteTableDetector () |
Create an object that can wait for a change in the route table or active network interfaces. More... | |
static PBoolean | GetInterfaceTable (InterfaceTable &table, PBoolean includeDown=false) |
Get a list of all interfaces. More... | |
static PString | GetInterface (const Address &addr) |
Get the interface name for the specified local IP address. More... | |
static Address | GetInterfaceAddress (const PString &ifName, unsigned version=4) |
Get the interface name for the specified local IP address. More... | |
static PString | GetInterfaceMACAddress (const char *ifName=NULL) |
Get MAC address of interface. More... | |
static Address | GetNetworkInterface (unsigned version=4) |
Get the address of the first interface to the "Internet". More... | |
static Address | GetGatewayAddress (unsigned 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. More... | |
static PString | GetGatewayInterface (unsigned 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. More... | |
static Address | GetGatewayInterfaceAddress (unsigned version=4) |
Get the IP address 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 Address | GetRouteInterfaceAddress (const Address &remoteAddress) |
Get the interface address that will be used to reach the specified remote address. More... | |
![]() | |
static int | Select (PSocket &sock1, PSocket &sock2) |
Select a socket with available data. More... | |
static int | Select (PSocket &sock1, PSocket &sock2, const PTimeInterval &timeout) |
Select a socket with available data. More... | |
static Errors | Select (SelectList &read) |
Select a socket with available data. More... | |
static Errors | Select (SelectList &read, const PTimeInterval &timeout) |
Select a socket with available data. More... | |
static Errors | Select (SelectList &read, SelectList &write) |
Select a socket with available data. More... | |
static Errors | Select (SelectList &read, SelectList &write, const PTimeInterval &timeout) |
Select a socket with available data. More... | |
static Errors | Select (SelectList &read, SelectList &write, SelectList &except) |
Select a socket with available data. More... | |
static Errors | Select (SelectList &read, SelectList &write, SelectList &except, const PTimeInterval &timeout) |
Select a socket with available data. More... | |
static WORD | Host2Net (WORD v) |
Convert from host to network byte order. More... | |
static DWORD | Host2Net (DWORD v) |
Convert from host to network byte order. More... | |
static WORD | Net2Host (WORD v) |
Convert from network to host byte order. More... | |
static DWORD | Net2Host (DWORD v) |
Convert from network to host byte order. More... | |
static WORD | GetProtocolByName (const PString &name) |
Get the number of the protocol associated with the specified name. More... | |
static PString | GetNameByProtocol (WORD proto) |
Get the name of the protocol number specified. More... | |
static WORD | GetPortByService (const char *protocol, const PString &service) |
Get the port number for the specified service name. More... | |
static PString | GetServiceByPort (const char *protocol, WORD port) |
Get the service name from the port number. More... | |
![]() | |
static PString | GetErrorText (Errors lastError, int osError=0) |
Get error message description. More... | |
![]() | |
static __inline void | CopyTraceContextIdentifier (PObject &to, const PObject &from) |
static __inline void | CopyTraceContextIdentifier (PObject &to, const PObject *from) |
static __inline void | CopyTraceContextIdentifier (PObject *to, const PObject &from) |
static __inline void | CopyTraceContextIdentifier (PObject *to, const PObject *from) |
static __inline const char * | Class () |
static __inline const PObject * | PTraceObjectInstance (const char *) |
static __inline const PObject * | PTraceObjectInstance (const PObject *obj) |
template<typename T > | |
static Comparison | Compare2 (T v1, T v2) |
Compare two types, returning Comparison type. More... | |
static Comparison | InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size) |
Internal function caled from CompareObjectMemoryDirect() More... | |
![]() | |
static unsigned | NoBufferRetryCount |
![]() | |
QoS | m_qos |
![]() | |
WORD | m_port |
Port to be used by the socket when opening the channel. More... | |
![]() | |
PTimeInterval | readTimeout |
Timeout for read operations. More... | |
PTimeInterval | writeTimeout |
Timeout for write operations. More... | |
atomic< P_INT_PTR > | os_handle |
The operating system file handle return by standard open() function. More... | |
PThreadLocalStorage< Status > | m_status [NumErrorGroups+1] |
PXBlockType | px_lastBlockType |
PThread * | px_readThread |
PThread * | px_writeThread |
PThread * | px_selectThread [3] |
PCriticalSection | px_selectMutex [3] |
![]() | |
unsigned | m_traceContextIdentifier |
Create a socket channel that uses allows ICMP commands in the Internal Protocol.
PICMPSocket::PICMPSocket | ( | ) |
Create a TCP/IP protocol socket channel.
If a remote machine address or a "listening" socket is specified then the channel is also opened.
|
protectedvirtual |
This function returns the protocol name for the socket type.
Implements PSocket.
|
protectedvirtual |
Open an IPv4 or IPv6 socket.
Implements PIPSocket.
Send an ECHO_REPLY message to the specified host and wait for a reply to be sent back.
host | Host to send ping. |
Send an ECHO_REPLY message to the specified host and wait for a reply to be sent back.
host | Host to send ping. |
info | Information on the ping and reply. |