Example of AWS IoT connection and Web Dashboard thru STM32 Nucleo evaluation board and mbed OS.

Dependencies:   X_NUCLEO_IKS01A1 mbed FP MQTTPacket DnsQuery ATParser

Embed: (wiki syntax)

« Back to documentation index

SocketAddress Class Reference

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:
ifaceNetwork stack to use for DNS resolution
hostHostname to resolve
portOptional 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:
hostNull-terminated representation of the IP address
portOptional 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:
bytesRaw IP address in big-endian order
versionIP address version, NSAPI_IPv4 or NSAPI_IPv6
portOptional 16-bit port

Definition at line 178 of file SocketAddress.cpp.

SocketAddress ( const SocketAddress addr )

Create a SocketAddress from another SocketAddress.

Parameters:
addressSocketAddress 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

Get the port.

Returns:
The 16-bit port

Definition at line 254 of file SocketAddress.cpp.

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:
addrNull-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:
bytesRaw IP address in big-endian order
versionIP address version, NSAPI_IPv4 or NSAPI_IPv6

Definition at line 208 of file SocketAddress.cpp.

void set_port ( uint16_t  port )

Set the port.

Parameters:
port16-bit port

Definition at line 224 of file SocketAddress.cpp.