boost::corosio::udp

Encapsulate the UDP protocol for socket creation.

Synopsis

Declared in <boost/corosio/udp.hpp>

class udp;

Description

This class identifies the UDP protocol and its address family (IPv4 or IPv6). It is used to parameterize udp_socket::open() calls with a self‐documenting type.

The family(), type(), and protocol() members return the three integers passed to the operating system's socket() call. Their values are platform‐defined constants taken from the system socket headers. For an inline variant that includes those headers, use native_udp.

Example

udp_socket sock( ioc );
sock.open( udp::v4() );
sock.bind( endpoint( ipv4_address::any(), 9000 ) );

Type Aliases

Name

Description

socket

The socket type to use with this protocol, udp_socket.

Member Functions

Name

Description

family

Return the address family (AF_INET or AF_INET6).

is_v6

Return true if this is IPv6.

Static Member Functions

Name

Description

protocol

Return the IP protocol (IPPROTO_UDP).

type

Return the socket type (SOCK_DGRAM).

v4

Construct an IPv4 UDP protocol.

v6

Construct an IPv6 UDP protocol.

Friends

Name

Description

boost::corosio::operator!=

Test for inequality.

boost::corosio::operator==

Test for equality.

See Also

native_udp, udp_socket

Created with MrDocs