Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SocketAddress Class Reference
SocketAddress class. More...
#include <SocketAddress.h>
Public Member Functions | |
template<typename S > | |
SocketAddress (S *stack, const char *host, uint16_t port=0) | |
Create a SocketAddress from a hostname and port. | |
SocketAddress (nsapi_addr_t addr=nsapi_addr_t(), uint16_t port=0) | |
Create a SocketAddress from a raw IP address and port. | |
SocketAddress (const char *addr, uint16_t port=0) | |
Create a SocketAddress from an IP address and port. | |
SocketAddress (const void *bytes, nsapi_version_t version, uint16_t port=0) | |
Create a SocketAddress from raw IP bytes, IP version, and port. | |
SocketAddress (const SocketAddress &addr) | |
Create a SocketAddress from another SocketAddress. | |
void | set_ip_address (const char *addr) |
Set the IP address. | |
void | set_ip_bytes (const void *bytes, nsapi_version_t version) |
Set the raw IP bytes and IP version. | |
void | set_addr (nsapi_addr_t addr) |
Set the raw IP address. | |
void | set_port (uint16_t port) |
Set the port. | |
const char * | get_ip_address () const |
Get the IP address. | |
nsapi_version_t | get_ip_version () const |
Get the IP address version. | |
nsapi_addr_t | get_addr () const |
Get the raw IP address. | |
uint16_t | get_port () const |
Get the port. | |
operator bool () const | |
Test if address is zero. |
Detailed Description
SocketAddress class.
Representation of an IP address and port pair.
Definition at line 32 of file SocketAddress.h.
Constructor & Destructor Documentation
SocketAddress | ( | S * | stack, |
const char * | host, | ||
uint16_t | port = 0 |
||
) |
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:
-
stack Network stack to use for DNS resolution host Hostname to resolve port Optional 16-bit port
Definition at line 46 of file SocketAddress.h.
SocketAddress | ( | nsapi_addr_t | addr = nsapi_addr_t() , |
uint16_t | port = 0 |
||
) |
Create a SocketAddress from a raw IP address and port.
- Parameters:
-
addr Raw IP address port Optional 16-bit port
Definition at line 146 of file SocketAddress.cpp.
SocketAddress | ( | const char * | addr, |
uint16_t | port = 0 |
||
) |
Create a SocketAddress from an IP address and port.
- Parameters:
-
host Null-terminated representation of the IP address port Optional 16-bit port
Definition at line 153 of file SocketAddress.cpp.
SocketAddress | ( | const void * | bytes, |
nsapi_version_t | version, | ||
uint16_t | port = 0 |
||
) |
Create a SocketAddress from raw IP bytes, IP version, and port.
- Parameters:
-
bytes Raw IP address in big-endian order version IP address version, NSAPI_IPv4 or NSAPI_IPv6 port Optional 16-bit port
Definition at line 160 of file SocketAddress.cpp.
SocketAddress | ( | const SocketAddress & | addr ) |
Create a SocketAddress from another SocketAddress.
- Parameters:
-
address SocketAddress to copy
Definition at line 167 of file SocketAddress.cpp.
Member Function Documentation
nsapi_addr_t get_addr | ( | ) | const |
const char * get_ip_address | ( | ) | const |
Get the IP address.
- Returns:
- Null-terminated representation of the IP Address
Definition at line 208 of file SocketAddress.cpp.
nsapi_version_t get_ip_version | ( | ) | const |
Get the IP address version.
- Returns:
- IP address version, NSAPI_IPv4 or NSAPI_IPv6
Definition at line 228 of file SocketAddress.cpp.
uint16_t get_port | ( | ) | const |
operator bool | ( | void | ) | const |
Test if address is zero.
- Returns:
- True if address is not zero
Definition at line 243 of file SocketAddress.cpp.
void set_addr | ( | nsapi_addr_t | addr ) |
Set the raw IP address.
- Parameters:
-
addr Raw IP address
Definition at line 197 of file SocketAddress.cpp.
void set_ip_address | ( | const char * | addr ) |
Set the IP address.
- Parameters:
-
addr Null-terminated represention of the IP address
Definition at line 174 of file SocketAddress.cpp.
void set_ip_bytes | ( | const void * | bytes, |
nsapi_version_t | version | ||
) |
Set the raw IP bytes and IP version.
- Parameters:
-
bytes Raw IP address in big-endian order version IP address version, NSAPI_IPv4 or NSAPI_IPv6
Definition at line 189 of file SocketAddress.cpp.
void set_port | ( | uint16_t | port ) |
Generated on Tue Jul 12 2022 12:58:54 by
