C++ Actor Framework 1.0.0
Loading...
Searching...
No Matches
caf::net::udp_datagram_socket Struct Reference

A datagram-oriented network communication endpoint for bidirectional byte transmission. More...

#include <udp_datagram_socket.hpp>

Inheritance diagram for caf::net::udp_datagram_socket:
caf::net::datagram_socket caf::net::network_socket caf::net::socket caf::detail::comparable< socket >

Public Types

using super = datagram_socket
 
- Public Types inherited from caf::net::datagram_socket
using super = network_socket
 
- Public Types inherited from caf::net::network_socket
using super = socket
 

Related Symbols

(Note that these are not member symbols.)

expected< udp_datagram_socket > CAF_NET_EXPORT make_udp_datagram_socket (ip_endpoint ep, bool reuse_addr=true)
 Creates a udp_datagram_socket bound to given port.
 
ptrdiff_t CAF_NET_EXPORT read (udp_datagram_socket x, byte_span buf, ip_endpoint *src=nullptr)
 Receives the next datagram on socket x.
 
ptrdiff_t CAF_NET_EXPORT write (udp_datagram_socket x, const_byte_span buf, ip_endpoint ep)
 Sends the content of buf as a datagram to the endpoint ep on socket x.
 

Additional Inherited Members

- Public Member Functions inherited from caf::net::socket
constexpr socket (socket_id id) noexcept
 
constexpr socket (const socket &other) noexcept=default
 
socketoperator= (const socket &other) noexcept=default
 
constexpr signed_socket_id compare (socket other) const noexcept
 
constexpr operator bool () const noexcept
 
constexpr bool operator! () const noexcept
 
constexpr socket fd () const noexcept
 
- Public Attributes inherited from caf::net::socket
socket_id id
 

Detailed Description

A datagram-oriented network communication endpoint for bidirectional byte transmission.

Friends And Related Symbol Documentation

◆ make_udp_datagram_socket()

expected< udp_datagram_socket > CAF_NET_EXPORT make_udp_datagram_socket ( ip_endpoint ep,
bool reuse_addr = true )
related

Creates a udp_datagram_socket bound to given port.

Parameters
epip_endpoint that contains the port to bind to. Pass port '0' to bind to any unused port - The endpoint will be updated with the specific port that was bound.
Returns
The connected socket or an error.

◆ read()

ptrdiff_t CAF_NET_EXPORT read ( udp_datagram_socket x,
byte_span buf,
ip_endpoint * src = nullptr )
related

Receives the next datagram on socket x.

Parameters
xThe UDP socket for receiving datagrams.
bufWritable output buffer.
srcIf non-null, CAF optionally stores the address of the sender for the datagram.
Returns
The number of received bytes on success, 0 if the socket is closed, or -1 in case of an error.
Postcondition
buf was modified and the resulting integer represents the length of the received datagram, even if it did not fit into the given buffer.

◆ write()

ptrdiff_t CAF_NET_EXPORT write ( udp_datagram_socket x,
const_byte_span buf,
ip_endpoint ep )
related

Sends the content of buf as a datagram to the endpoint ep on socket x.

Parameters
xThe UDP socket for sending datagrams.
bufThe buffer to send.
epThe endpoint to send the datagram to.
Returns
The number of written bytes on success, otherwise an error code.

The documentation for this struct was generated from the following file: