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.
Dependents: mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510
SocketAddress Class Reference
[Netsocket]
SocketAddress class. More...
#include <SocketAddress.h>
Public Member Functions | |
template<typename S > | |
MBED_DEPRECATED_SINCE ("mbed-os-5.1.3","Constructors hide possible errors. Replaced by ""NetworkInterface::gethostbyname.") SocketAddress(S *stack | |
Create a SocketAddress from a hostname 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. | |
bool | 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. | |
Friends | |
bool | operator== (const SocketAddress &a, const SocketAddress &b) |
Compare two addresses for equality. | |
bool | operator!= (const SocketAddress &a, const SocketAddress &b) |
Compare two addresses for equality. |
Detailed Description
SocketAddress class.
Representation of an IP address and port pair.
Definition at line 35 of file SocketAddress.h.
Constructor & Destructor Documentation
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 164 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 171 of file SocketAddress.cpp.
SocketAddress | ( | const SocketAddress & | addr ) |
Create a SocketAddress from another SocketAddress.
- Parameters:
-
address SocketAddress to copy
Definition at line 178 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 228 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 250 of file SocketAddress.cpp.
uint16_t get_port | ( | ) | const |
MBED_DEPRECATED_SINCE | ( | "mbed-os-5.1.3" | , |
"Constructors hide possible errors. Replaced by ""NetworkInterface::gethostbyname." | |||
) |
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
operator bool | ( | ) | const |
Test if address is zero.
- Returns:
- True if address is not zero
Definition at line 265 of file SocketAddress.cpp.
void set_addr | ( | nsapi_addr_t | addr ) |
Set the raw IP address.
- Parameters:
-
addr Raw IP address
Definition at line 217 of file SocketAddress.cpp.
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
Definition at line 185 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 203 of file SocketAddress.cpp.
void set_port | ( | uint16_t | 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
Definition at line 303 of file SocketAddress.cpp.
bool operator== | ( | const SocketAddress & | a, |
const SocketAddress & | b | ||
) | [friend] |
Compare two addresses for equality.
- Returns:
- True if both addresses are equal
Definition at line 288 of file SocketAddress.cpp.
Generated on Tue Jul 12 2022 11:03:19 by
