Mistake on this page?
Report an issue in GitHub or email us
Public Member Functions | Friends
SocketAddress Class Reference

Public Member Functions

template<typename S >
 SocketAddress (S *stack, const char *host, uint16_t port=0)
 
 SocketAddress (nsapi_addr_t addr=nsapi_addr_t(), uint16_t port=0)
 
 SocketAddress (const char *addr, uint16_t port=0)
 
 SocketAddress (const void *bytes, nsapi_version_t version, uint16_t port=0)
 
 SocketAddress (const SocketAddress &addr)
 
bool set_ip_address (const char *addr)
 
void set_ip_bytes (const void *bytes, nsapi_version_t version)
 
void set_addr (nsapi_addr_t addr)
 
void set_port (uint16_t port)
 
const char * get_ip_address () const
 
const void * get_ip_bytes () const
 
nsapi_version_t get_ip_version () const
 
nsapi_addr_t get_addr () const
 
uint16_t get_port () const
 
 operator bool () const
 

Friends

bool operator== (const SocketAddress &a, const SocketAddress &b)
 
bool operator!= (const SocketAddress &a, const SocketAddress &b)
 

Constructor & Destructor Documentation

template<typename S >
SocketAddress::SocketAddress ( S *  stack,
const char *  host,
uint16_t  port = 0 
)
inline

Create a SocketAddress from a hostname and port

The hostname may be either a domain name or an IP address. If the hostname is an IP address, no network transactions will be performed.

On failure, the IP address and port will be set to zero

Parameters
stackNetwork stack to use for DNS resolution
hostHostname to resolve
portOptional 16-bit port
Deprecated:
Constructors hide possible errors. Replaced by NetworkInterface::gethostbyname.
SocketAddress::SocketAddress ( nsapi_addr_t  addr = nsapi_addr_t(),
uint16_t  port = 0 
)

Create a SocketAddress from a raw IP address and port

Parameters
addrRaw IP address
portOptional 16-bit port
SocketAddress::SocketAddress ( const char *  addr,
uint16_t  port = 0 
)

Create a SocketAddress from an IP address and port

Parameters
addrNull-terminated representation of the IP address
portOptional 16-bit port
SocketAddress::SocketAddress ( const void *  bytes,
nsapi_version_t  version,
uint16_t  port = 0 
)

Create a SocketAddress from raw IP bytes, IP version, and port

Parameters
bytesRaw IP address in big-endian order
versionIP address version, NSAPI_IPv4 or NSAPI_IPv6
portOptional 16-bit port
SocketAddress::SocketAddress ( const SocketAddress addr)

Create a SocketAddress from another SocketAddress

Parameters
addrSocketAddress to copy

Member Function Documentation

nsapi_addr_t SocketAddress::get_addr ( ) const

Get the raw IP address

Returns
Raw IP address
const char * SocketAddress::get_ip_address ( ) const

Get the IP address

Returns
Null-terminated representation of the IP Address
nsapi_version_t SocketAddress::get_ip_version ( ) const

Get the IP address version

Returns
IP address version, NSAPI_IPv4 or NSAPI_IPv6
uint16_t SocketAddress::get_port ( ) const

Get the port

Returns
The 16-bit port
SocketAddress::operator bool ( ) const

Test if address is zero

Returns
True if address is not zero
void SocketAddress::set_addr ( nsapi_addr_t  addr)

Set the raw IP address

Parameters
addrRaw IP address
bool SocketAddress::set_ip_address ( const char *  addr)

Set the IP address

Parameters
addrNull-terminated represention of the IP address
Returns
True if address is a valid representation of an IP address, otherwise False and SocketAddress is set to null
void SocketAddress::set_ip_bytes ( const void *  bytes,
nsapi_version_t  version 
)

Set the raw IP bytes and IP version

Parameters
bytesRaw IP address in big-endian order
versionIP address version, NSAPI_IPv4 or NSAPI_IPv6
void SocketAddress::set_port ( uint16_t  port)

Set the port

Parameters
port16-bit port

Friends And Related Function Documentation

bool operator!= ( const SocketAddress a,
const SocketAddress b 
)
friend

Compare two addresses for equality

Returns
True if both addresses are not equal
bool operator== ( const SocketAddress a,
const SocketAddress b 
)
friend

Compare two addresses for equality

Returns
True if both addresses are equal

The documentation for this class was generated from the following files:
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.