Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
Poco::Net::SocketAddress Class Reference

#include <SocketAddress.h>

+ Collaboration diagram for Poco::Net::SocketAddress:

Public Types

enum  { MAX_ADDRESS_LENGTH }
 
using Family = AddressFamily::Family
 

Public Member Functions

 SocketAddress ()
 
 SocketAddress (Family family)
 Creates a wildcard (all zero) IPv4 SocketAddress.
 
 SocketAddress (const IPAddress &hostAddress, Poco::UInt16 portNumber)
 
 SocketAddress (Poco::UInt16 port)
 Creates a SocketAddress from an IP address and given port number.
 
 SocketAddress (Family family, Poco::UInt16 port)
 
 SocketAddress (const std::string &hostAddress, Poco::UInt16 portNumber)
 
 SocketAddress (Family family, const std::string &hostAddress, Poco::UInt16 portNumber)
 
 SocketAddress (const std::string &hostAddress, const std::string &portNumber)
 
 SocketAddress (Family family, const std::string &hostAddress, const std::string &portNumber)
 
 SocketAddress (const std::string &hostAndPort)
 
 SocketAddress (Family family, const std::string &addr)
 
 SocketAddress (const SocketAddress &addr)
 
 SocketAddress (const struct sockaddr *addr, poco_socklen_t length)
 Creates a SocketAddress by copying another one.
 
 ~SocketAddress ()
 Creates a SocketAddress from a native socket address.
 
SocketAddressoperator= (const SocketAddress &socketAddress)
 Destroys the SocketAddress.
 
IPAddress host () const
 Assigns another SocketAddress.
 
Poco::UInt16 port () const
 Returns the host IP address.
 
poco_socklen_t length () const
 Returns the port number.
 
const struct sockaddr * addr () const
 Returns the length of the internal native socket address.
 
int af () const
 Returns a pointer to the internal native socket address.
 
std::string toString () const
 Returns the address family (AF_INET or AF_INET6) of the address.
 
Family family () const
 Returns a string representation of the address.
 
bool operator< (const SocketAddress &socketAddress) const
 Returns the address family of the host's address.
 
bool operator== (const SocketAddress &socketAddress) const
 
bool operator!= (const SocketAddress &socketAddress) const
 

Static Public Attributes

static const Family IPv4 = AddressFamily::IPv4
 

Protected Member Functions

void init (const IPAddress &hostAddress, Poco::UInt16 portNumber)
 
void init (const std::string &hostAddress, Poco::UInt16 portNumber)
 
void init (Family family, const std::string &hostAddress, Poco::UInt16 portNumber)
 
void init (Family family, const std::string &address)
 
void init (const std::string &hostAndPort)
 
Poco::UInt16 resolveService (const std::string &service)
 

Private Types

typedef Poco::Net::Impl::SocketAddressImpl Impl
 
typedef Poco::AutoPtr< ImplPtr
 

Private Member Functions

Ptr pImpl () const
 
void newIPv4 ()
 
void newIPv4 (const sockaddr_in *)
 
void newIPv4 (const IPAddress &hostAddress, Poco::UInt16 portNumber)
 

Private Attributes

Ptr _pImpl
 

Detailed Description

This class represents an internet (IP) endpoint/socket address. The address can belong either to the IPv4 or the IPv6 address family and consists of a host address and a port number.

Definition at line 37 of file SocketAddress.h.

Member Typedef Documentation

◆ Family

◆ Impl

◆ Ptr

Definition at line 198 of file SocketAddress.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
MAX_ADDRESS_LENGTH 

Definition at line 175 of file SocketAddress.h.

Constructor & Destructor Documentation

◆ SocketAddress() [1/13]

Poco::Net::SocketAddress::SocketAddress ( )

◆ SocketAddress() [2/13]

Poco::Net::SocketAddress::SocketAddress ( Family family)
explicit

Creates a wildcard (all zero) IPv4 SocketAddress.

◆ SocketAddress() [3/13]

Poco::Net::SocketAddress::SocketAddress ( const IPAddress & hostAddress,
Poco::UInt16 portNumber )

Creates a SocketAddress with unspecified (wildcard) IP address of the given family.

◆ SocketAddress() [4/13]

Poco::Net::SocketAddress::SocketAddress ( Poco::UInt16 port)
explicit

Creates a SocketAddress from an IP address and given port number.

◆ SocketAddress() [5/13]

Poco::Net::SocketAddress::SocketAddress ( Family family,
Poco::UInt16 port )

Creates a SocketAddress with unspecified (wildcard) IP address and given port number.

◆ SocketAddress() [6/13]

Poco::Net::SocketAddress::SocketAddress ( const std::string & hostAddress,
Poco::UInt16 portNumber )

Creates a SocketAddress with unspecified (wildcard) IP address of the given family, and given port number.

◆ SocketAddress() [7/13]

Poco::Net::SocketAddress::SocketAddress ( Family family,
const std::string & hostAddress,
Poco::UInt16 portNumber )

Creates a SocketAddress from an IP address and given port number.

The IP address must either be a domain name, or it must be in dotted decimal (IPv4) or hex string (IPv6) format.

◆ SocketAddress() [8/13]

Poco::Net::SocketAddress::SocketAddress ( const std::string & hostAddress,
const std::string & portNumber )

Creates a SocketAddress from an IP address and given port number.

The IP address must either be a domain name, or it must be in dotted decimal (IPv4) or hex string (IPv6) format.

If a domain name is given in hostAddress, it is resolved and the address matching the given family is used. If no address matching the given family is found, or the IP address given in hostAddress does not match the given family, an AddressFamilyMismatchException is thrown.

◆ SocketAddress() [9/13]

Poco::Net::SocketAddress::SocketAddress ( Family family,
const std::string & hostAddress,
const std::string & portNumber )

Creates a SocketAddress from an IP address and the service name or port number.

The IP address must either be a domain name, or it must be in dotted decimal (IPv4) or hex string (IPv6) format.

The given port must either be a decimal port number, or a service name.

◆ SocketAddress() [10/13]

Poco::Net::SocketAddress::SocketAddress ( const std::string & hostAndPort)
explicit

Creates a SocketAddress from an IP address and the service name or port number.

The IP address must either be a domain name, or it must be in dotted decimal (IPv4) or hex string (IPv6) format.

The given port must either be a decimal port number, or a service name.

If a domain name is given in hostAddress, it is resolved and the address matching the given family is used. If no address matching the given family is found, or the IP address given in hostAddress does not match the given family, an AddressFamilyMismatchException is thrown.

◆ SocketAddress() [11/13]

Poco::Net::SocketAddress::SocketAddress ( Family family,
const std::string & addr )

Creates a SocketAddress from an IP address or host name and the port number/service name. Host name/address and port number must be separated by a colon. In case of an IPv6 address, the address part must be enclosed in brackets.

Examples: 192.168.1.10:80

www.appinf.com:8080

On POSIX platforms supporting UNIX_LOCAL sockets, hostAndPort can also be the absolute path of a local socket, starting with a slash, e.g. "/tmp/local.socket".

◆ SocketAddress() [12/13]

Poco::Net::SocketAddress::SocketAddress ( const SocketAddress & addr)

Creates a SocketAddress of the given family from a string representation of the address, which is either an IP address and port number, separated by a colon for IPv4 or IPv6 addresses, or a path for UNIX_LOCAL sockets.

◆ SocketAddress() [13/13]

Poco::Net::SocketAddress::SocketAddress ( const struct sockaddr * addr,
poco_socklen_t length )

Creates a SocketAddress by copying another one.

◆ ~SocketAddress()

Poco::Net::SocketAddress::~SocketAddress ( )

Creates a SocketAddress from a native socket address.

Member Function Documentation

◆ addr()

const struct sockaddr * Poco::Net::SocketAddress::addr ( ) const

Returns the length of the internal native socket address.

◆ af()

int Poco::Net::SocketAddress::af ( ) const

Returns a pointer to the internal native socket address.

◆ family()

Family Poco::Net::SocketAddress::family ( ) const

Returns a string representation of the address.

◆ host()

IPAddress Poco::Net::SocketAddress::host ( ) const

Assigns another SocketAddress.

+ Here is the caller graph for this function:

◆ init() [1/5]

void Poco::Net::SocketAddress::init ( const IPAddress & hostAddress,
Poco::UInt16 portNumber )
protected

◆ init() [2/5]

void Poco::Net::SocketAddress::init ( const std::string & hostAddress,
Poco::UInt16 portNumber )
protected

◆ init() [3/5]

void Poco::Net::SocketAddress::init ( const std::string & hostAndPort)
protected

◆ init() [4/5]

void Poco::Net::SocketAddress::init ( Family family,
const std::string & address )
protected

◆ init() [5/5]

void Poco::Net::SocketAddress::init ( Family family,
const std::string & hostAddress,
Poco::UInt16 portNumber )
protected

◆ length()

poco_socklen_t Poco::Net::SocketAddress::length ( ) const

Returns the port number.

◆ newIPv4() [1/3]

void Poco::Net::SocketAddress::newIPv4 ( )
inlineprivate

Definition at line 230 of file SocketAddress.h.

+ Here is the call graph for this function:

◆ newIPv4() [2/3]

void Poco::Net::SocketAddress::newIPv4 ( const IPAddress & hostAddress,
Poco::UInt16 portNumber )
inlineprivate

Definition at line 242 of file SocketAddress.h.

+ Here is the call graph for this function:

◆ newIPv4() [3/3]

void Poco::Net::SocketAddress::newIPv4 ( const sockaddr_in * sockAddr)
inlineprivate

Definition at line 236 of file SocketAddress.h.

+ Here is the call graph for this function:

◆ operator!=()

bool Poco::Net::SocketAddress::operator!= ( const SocketAddress & socketAddress) const
inline

Definition at line 287 of file SocketAddress.h.

+ Here is the call graph for this function:

◆ operator<()

bool Poco::Net::SocketAddress::operator< ( const SocketAddress & socketAddress) const

Returns the address family of the host's address.

◆ operator=()

SocketAddress & Poco::Net::SocketAddress::operator= ( const SocketAddress & socketAddress)

Destroys the SocketAddress.

◆ operator==()

bool Poco::Net::SocketAddress::operator== ( const SocketAddress & socketAddress) const
inline

Definition at line 276 of file SocketAddress.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pImpl()

SocketAddress::Ptr Poco::Net::SocketAddress::pImpl ( ) const
inlineprivate

Definition at line 223 of file SocketAddress.h.

◆ port()

Poco::UInt16 Poco::Net::SocketAddress::port ( ) const

Returns the host IP address.

+ Here is the caller graph for this function:

◆ resolveService()

Poco::UInt16 Poco::Net::SocketAddress::resolveService ( const std::string & service)
protected

◆ toString()

std::string Poco::Net::SocketAddress::toString ( ) const

Returns the address family (AF_INET or AF_INET6) of the address.

Member Data Documentation

◆ _pImpl

Ptr Poco::Net::SocketAddress::_pImpl
private

Definition at line 216 of file SocketAddress.h.

◆ IPv4

const Family Poco::Net::SocketAddress::IPv4 = AddressFamily::IPv4
static

Definition at line 48 of file SocketAddress.h.


The documentation for this class was generated from the following file: