SocketAddress class.
More...
#include <SocketAddress.h>
SocketAddress class.
Representation of an IP address and port pair.
Definition at line 37 of file SocketAddress.h.
◆ SocketAddress() [1/5]
◆ SocketAddress() [2/5]
◆ SocketAddress() [3/5]
Create a SocketAddress from an IP address and port.
- Parameters
-
addr | Null-terminated representation of the IP address |
port | Optional 16-bit port, defaults to 0 |
◆ SocketAddress() [4/5]
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, defaults to 0 |
◆ SocketAddress() [5/5]
◆ ~SocketAddress()
◆ set_ip_address()
bool set_ip_address |
( |
const char * |
addr | ) |
|
Set the IP address.
- Parameters
-
addr | Null-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
◆ set_ip_bytes()
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 |
◆ set_addr()
Set the raw IP address.
- Parameters
-
◆ set_port()
void set_port |
( |
uint16_t |
port | ) |
|
◆ get_ip_address()
const char * get_ip_address |
( |
| ) |
const |
Get the human-readable IP address.
Allocates memory for a string and converts binary address to human-readable format. String is freed in the destructor.
- Returns
- Null-terminated representation of the IP Address
◆ get_ip_bytes()
const void * get_ip_bytes |
( |
| ) |
const |
Get the raw IP bytes.
- Returns
- Raw IP address in big-endian order
Definition at line 119 of file SocketAddress.h.
◆ get_ip_version()
nsapi_version_t get_ip_version |
( |
| ) |
const |
Get the IP address version.
- Returns
- IP address version, NSAPI_IPv4 or NSAPI_IPv6
Definition at line 128 of file SocketAddress.h.
◆ get_addr()
Get the raw IP address.
- Returns
- Raw IP address
Definition at line 137 of file SocketAddress.h.
◆ get_port()
uint16_t get_port |
( |
| ) |
const |
◆ operator bool()
Test if address is zero.
- Returns
- True if address is not zero
◆ operator=()
Copy address from another SocketAddress.
- Parameters
-
- Return values
-