Base class for IP Based Networking Libraries
Dependencies: DnsQuery
Dependents: TempTower BSDInterfaceTests HelloBSDInterface ESP8266InterfaceTests ... more
SocketAddress Class Reference
SocketAddress class. More...
#include <SocketAddress.h>
Public Member Functions | |
SocketAddress (NetworkStack *iface, const char *host, uint16_t port=0) | |
Create a SocketAddress from a hostname and port. | |
SocketAddress (const char *addr=0, 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 a raw IP address 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 address. | |
void | set_port (uint16_t port) |
Set the port. | |
const char * | get_ip_address () const |
Get the IP address. | |
const void * | get_ip_bytes () const |
Get the raw IP address. | |
nsapi_version_t | get_ip_version () const |
Get the IP address version. | |
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 74 of file SocketAddress.h.
Constructor & Destructor Documentation
SocketAddress | ( | NetworkStack * | iface, |
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:
-
iface Network stack to use for DNS resolution host Hostname to resolve port Optional 16-bit port
Definition at line 145 of file SocketAddress.cpp.
SocketAddress | ( | const char * | addr = 0 , |
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 171 of file SocketAddress.cpp.
SocketAddress | ( | const void * | bytes, |
nsapi_version_t | version, | ||
uint16_t | port = 0 |
||
) |
Create a SocketAddress from a raw IP address 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 178 of file SocketAddress.cpp.
SocketAddress | ( | const SocketAddress & | addr ) |
Create a SocketAddress from another SocketAddress.
- Parameters:
-
address SocketAddress to copy
Definition at line 185 of file SocketAddress.cpp.
Member Function Documentation
const char * get_ip_address | ( | ) | const |
Get the IP address.
- Returns:
- Null-terminated representation of the IP Address
Definition at line 229 of file SocketAddress.cpp.
const void * get_ip_bytes | ( | ) | const |
Get the raw IP address.
- Returns:
- Raw IP address in big-endian order
Definition at line 244 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 249 of file SocketAddress.cpp.
uint16_t get_port | ( | ) | const |
operator bool | ( | ) | const |
Test if address is zero.
- Returns:
- True if address is not zero
Definition at line 259 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 192 of file SocketAddress.cpp.
void set_ip_bytes | ( | const void * | bytes, |
nsapi_version_t | version | ||
) |
Set the raw IP address.
- Parameters:
-
bytes Raw IP address in big-endian order version IP address version, NSAPI_IPv4 or NSAPI_IPv6
Definition at line 208 of file SocketAddress.cpp.
void set_port | ( | uint16_t | port ) |
Generated on Tue Jul 12 2022 14:52:52 by 1.7.2