RTP Audio System  2.0.0
SocketAddress Class Reference

Socket Address. More...

#include <socketaddress.h>

Inheritance diagram for SocketAddress:
InternetAddress PacketAddress UnixAddress InternetFlow

List of all members.

Public Types

enum  PrintFormat {
  PF_Address = (1 << 0), PF_Hostname = (1 << 1), PF_Full = (PF_Address | PF_Hostname), PF_HidePort = (1 << 15),
  PF_Legacy = (1 << 16), PF_Default = (PF_Address | PF_Legacy)
}

Public Member Functions

virtual ~SocketAddress ()
virtual SocketAddressduplicate () const =0
virtual void reset ()=0
virtual bool isValid () const =0
cardinal getPrintFormat () const
void setPrintFormat (const cardinal format)
virtual card16 getPort () const =0
virtual void setPort (const card16 port)=0
virtual integer getFamily () const =0
virtual String getAddressString (const cardinal format=PF_Default) const =0
virtual cardinal getSystemAddress (sockaddr *buffer, const socklen_t length, const cardinal type=AF_UNSPEC) const =0
virtual bool setSystemAddress (const sockaddr *address, const socklen_t length)=0

Static Public Member Functions

static SocketAddressgetLocalAddress (const SocketAddress &peer)
static SocketAddresscreateSocketAddress (const integer family)
static SocketAddresscreateSocketAddress (const cardinal flags, const String &name)
static SocketAddresscreateSocketAddress (const cardinal flags, const String &name, const card16 port)
static SocketAddresscreateSocketAddress (const cardinal flags, sockaddr *address, const socklen_t length)
static SocketAddress ** newAddressList (const cardinal entries)
static void deleteAddressList (SocketAddress **&addressArray)

Static Public Attributes

static const cardinal MaxSockLen

Protected Attributes

cardinal Format

Friends

std::ostream & operator<< (std::ostream &os, const SocketAddress &sa)

Detailed Description

Socket Address.

This class is an interface for a socket address.

Author:
Thomas Dreibholz
Version:
1.0

Member Enumeration Documentation

setPrintFormat() printing formats.

Enumerator:
PF_Address 

Print address.

PF_Hostname 

Print hostname, if possible. Otherwise, print address.

PF_Full 

Print both, address and hostname (if resolvable).

PF_HidePort 

Hide port number.

PF_Legacy 

Legacy mode: Do *not* print IPv4 addresses on IPv6-capable hosts as IPv4-mapped address. That is, 1.2.3.4 instead of ::ffff:1.2.3.4.

PF_Default 

Default print format.


Constructor & Destructor Documentation

Destructor.


Member Function Documentation

Create SocketAddress object for given address family.

Parameters:
familyAddress family (e.g. AF_INET or AF_UNIX).
Returns:
SocketAddress object or NULL in case of failure.
SocketAddress * SocketAddress::createSocketAddress ( const cardinal  flags,
const String name 
) [static]

Create SocketAddress object from address string.

Parameters:
flagsflags
stringAddress string.
Returns:
SocketAddress object or NULL in case of failure.
SocketAddress * SocketAddress::createSocketAddress ( const cardinal  flags,
const String name,
const card16  port 
) [static]

Create SocketAddress object from address string and port number.

Parameters:
flagsflags
stringAddress string.
portPort number.
Returns:
SocketAddress object or NULL in case of failure.
SocketAddress * SocketAddress::createSocketAddress ( const cardinal  flags,
sockaddr *  address,
const socklen_t  length 
) [static]

Create SocketAddress object from system's sockaddr structure.

Parameters:
flagsflags.
addresssockaddr.
lengthLength of sockaddr.
Returns:
SocketAddress object or NULL in case of failure.
void SocketAddress::deleteAddressList ( SocketAddress **&  addressArray) [static]

Deallocate NULL-terminated list of SocketAddress objects.

Parameters:
addressArrayAddress list.
See also:
getLocalAddresses
accept
virtual SocketAddress* SocketAddress::duplicate ( ) const [pure virtual]

Create a duplicate of the SocketAddress object.

Returns:
Copy of SocketAddress object.

Implemented in InternetAddress, PacketAddress, UnixAddress, and InternetFlow.

virtual String SocketAddress::getAddressString ( const cardinal  format = PF_Default) const [pure virtual]

Get address string.

Returns:
Address string.

Implemented in InternetAddress, PacketAddress, UnixAddress, and InternetFlow.

virtual integer SocketAddress::getFamily ( ) const [pure virtual]

Get family of address.

Returns:
Address family (e.g. AF_INET or AF_UNIX).

Implemented in InternetAddress, PacketAddress, and UnixAddress.

Get the local host address. The parameter peer gives the address of the other host.

Parameters:
peerAddress of peer.
Returns:
Local SocketAddress or NULL in case of an error.

Examples: localhost => localhost address (127.0.0.1 or ::1). ethernet-host => ethernet interface address. internet-address => dynamic-ip address set by pppd.

virtual card16 SocketAddress::getPort ( ) const [pure virtual]

Get port of address.

Returns:
Port.

Implemented in InternetAddress, PacketAddress, and UnixAddress.

Get printing format.

Returns:
Print format.
virtual cardinal SocketAddress::getSystemAddress ( sockaddr *  buffer,
const socklen_t  length,
const cardinal  type = AF_UNSPEC 
) const [pure virtual]

Get system's sockaddr structure for the address.

Parameters:
bufferBuffer to write sockaddr to.
lengthLength of buffer.
typeSocket address type, e.g. AF_INET or AF_INET6.
Returns:
Length of written sockaddr structure.

Implemented in InternetAddress, PacketAddress, UnixAddress, and InternetFlow.

virtual bool SocketAddress::isValid ( ) const [pure virtual]

Check, if address is valid.

Returns:
true, if address is valid; false otherwise.

Implemented in InternetAddress, PacketAddress, and UnixAddress.

SocketAddress ** SocketAddress::newAddressList ( const cardinal  entries) [static]

Allocate memory for NULL-terminated SocketAddress list with given number of entries.

Parameters:
entriesNumber of entries.
Returns:
Address list or NULL, if out of memory.
virtual void SocketAddress::reset ( ) [pure virtual]

Reset address.

Implemented in InternetAddress, PacketAddress, UnixAddress, and InternetFlow.

virtual void SocketAddress::setPort ( const card16  port) [pure virtual]

Set port of address.

Implemented in InternetAddress, PacketAddress, and UnixAddress.

void SocketAddress::setPrintFormat ( const cardinal  format) [inline]

Set printing format.

Parameters:
formatPrint format.
virtual bool SocketAddress::setSystemAddress ( const sockaddr *  address,
const socklen_t  length 
) [pure virtual]

Initialize the socket address from the system's sockaddr structure.

Parameters:
addresssockaddr.
lengthLength of sockaddr.

Implemented in InternetAddress, PacketAddress, and UnixAddress.


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const SocketAddress sa 
) [friend]

Output operator.


Member Data Documentation

Print format.

Initial value:
      (sizeof(sockaddr_un) > sizeof(sockaddr_storage)) ? sizeof(sockaddr_un) : sizeof(sockaddr_storage)

Maximum sockaddr length in bytes.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines