dpp::address_t
socket.h
sockaddr sockaddr dpp::address_t::socket_addr socket_addr dpp::address_t::socket_addr {}

Internal sockaddr struct.

dpp::address_t::address_t
(const std::string_view ip="0.0.0.0", uint16_t port=0)
address_t
dpp::address_t::address_t
const std::string_view ip "0.0.0.0"
uint16_t port 0

Create a new address_t.

ip

IPv4 address

port

Port number

Leave both as defaults to create a default bind-to-any setting

uint16_t uint16_t dpp::address_t::get_port (socket fd) get_port dpp::address_t::get_port socket fd

Get the port bound to a file descriptor.

fd

File descriptor

Port number, or 0 if no port bound

sockaddr * sockaddr * dpp::address_t::get_socket_address () get_socket_address dpp::address_t::get_socket_address

Get sockaddr.

sockaddr pointer

size_t size_t dpp::address_t::size () size dpp::address_t::size

Returns size of sockaddr_in.

sockaddr_in size

It is important the size this returns is sizeof(sockaddr_in) not sizeof(sockaddr), this is NOT a bug but requirement of C socket functions.

Represents an IPv4 address for use with socket functions such as bind().

Avoids type punning with C style casts from sockaddr_in to sockaddr pointers.

- dpp::address_t
  address_t
- dpp::address_t
  get_port
- dpp::address_t
  get_socket_address
- dpp::address_t
  size
- dpp::address_t
  socket_addr