|
|
This class is an interface for a socket address.
~SocketAddress ()
| ~SocketAddress |
[virtual]
Destructor.
void reset ()
| reset |
[pure virtual]
Reset address.
bool isValid ()
| isValid |
[const pure virtual]
Check, if address is valid.
Returns: true, if address is valid; false otherwise.
enum PrintFormat { PF_Address = (1 << 0), /** } | PrintFormat |
Print address.
inline cardinal getPrintFormat ()
| getPrintFormat |
[const]
Get printing format.
Returns: Print format.
inline void setPrintFormat (const cardinal format)
| setPrintFormat |
Set printing format.
Parameters:
format | Print format. |
card16 getPort ()
| getPort |
[const pure virtual]
Get port of address.
Returns: Port.
void setPort (const card16 port)
| setPort |
[pure virtual]
Set port of address.
integer getFamily ()
| getFamily |
[const pure virtual]
Get family of address.
Returns: Address family (e.g. AF_INET or AF_UNIX).
SocketAddress* getLocalAddress (const SocketAddress& peer)
| getLocalAddress |
[static]
Get the local host address. The parameter peer gives the address of the other host.
Examples: localhost => localhost address (127.0.0.1 or ::1). ethernet-host => ethernet interface address. internet-address => dynamic-ip address set by pppd.
Parameters:
peer | Address of peer. |
Returns: Local SocketAddress or NULL in case of an error.
String getAddressString (const cardinal format = PF_Default)
| getAddressString |
[const pure virtual]
Get address string.
Returns: Address string.
SocketAddress* createSocketAddress (const integer family)
| createSocketAddress |
[static]
Create SocketAddress object for given address family.
Parameters:
family | Address family (e.g. AF_INET or AF_UNIX). |
Returns: SocketAddress object or NULL in case of failure.
SocketAddress* createSocketAddress (const cardinal flags, const String& name)
| createSocketAddress |
[static]
Create SocketAddress object from address string.
Parameters:
flags | flags |
string | Address string. |
Returns: SocketAddress object or NULL in case of failure.
SocketAddress* createSocketAddress (const cardinal flags,
const String& name,
const card16 port)
| createSocketAddress |
[static]
Create SocketAddress object from address string and port number.
Parameters:
flags | flags |
string | Address string. |
port | Port number. |
Returns: SocketAddress object or NULL in case of failure.
SocketAddress* createSocketAddress (const cardinal flags,
sockaddr* address,
const socklen_t length)
| createSocketAddress |
[static]
Create SocketAddress object from system's sockaddr structure.
Parameters:
flags | flags. |
address | sockaddr. |
length | Length of sockaddr. |
Returns: SocketAddress object or NULL in case of failure.
cardinal getSystemAddress (sockaddr* buffer,
const socklen_t length,
const cardinal type = AF_UNSPEC)
| getSystemAddress |
[const pure virtual]
Get system's sockaddr structure for the address.
Parameters:
buffer | Buffer to write sockaddr to. |
length | Length of buffer. |
type | Socket address type, e.g. AF_INET or AF_INET6. |
Returns: Length of written sockaddr structure.
bool setSystemAddress (sockaddr* address, const socklen_t length)
| setSystemAddress |
[pure virtual]
Initialize the socket address from the system's sockaddr structure.
Parameters:
address | sockaddr. |
length | Length of sockaddr. |
SocketAddress** newAddressList (const cardinal entries)
| newAddressList |
[static]
Allocate memory for NULL-terminated SocketAddress list with given number of entries.
Parameters:
entries | Number of entries. |
Returns: Address list or NULL, if out of memory.
void deleteAddressList (SocketAddress**& addressArray)
| deleteAddressList |
[static]
Deallocate NULL-terminated list of SocketAddress objects.
Parameters:
addressArray | Address list. |
See also: getLocalAddresses, accept
static const cardinal MaxSockLen | MaxSockLen |
cardinal Format | Format |
[protected]
friend inline ostream& operator<< (ostream& os, const SocketAddress& sa)
| operator<< |
[protected]
Print format.