scclib
Stable Cloud Computing C++ Library
Public Member Functions | List of all members
scc::net::InetUdpSock Class Reference

Internet user datagram protocol (udp) socket. More...

#include <inet.h>

Inheritance diagram for scc::net::InetUdpSock:
Inheritance graph
[legend]
Collaboration diagram for scc::net::InetUdpSock:
Collaboration graph
[legend]

Public Member Functions

 InetUdpSock ()
 Create an IPv6 datagram socket.
 
virtual void reset ()
 Reset the socket.
 
InetAddr get_addr ()
 Get the socket address.
 
void mcast_join_group (const InetAddr &, unsigned=0)
 Join a multicast group. More...
 
void mcast_leave_group (const InetAddr &, unsigned=0)
 Leave a multicast group.
 
void mcast_interface (unsigned=0)
 Set the default interface for outgoing multicast messages. More...
 
void mcast_loopback (bool=true)
 Enable or disable multicast loopback. More...
 
void mcast_hops (unsigned=1)
 Hop limit for outgoing multicast messages. More...
 
- Public Member Functions inherited from scc::net::UdpSocket
size_t recv (void *loc, size_t len, SockaddrBase &s)
 Receive bytes (a datagram), setting the socket address of the peer. More...
 
size_t recv (void *loc, size_t len, SockaddrBase &s, std::error_code &e) noexcept
 Receive bytes (a datagram), setting the socket address of the peer, and the error code. More...
 
size_t send (const void *loc, size_t len, const SockaddrBase &d)
 Send bytes (a datagram) to a peer address. More...
 
size_t send (const void *loc, size_t len, const SockaddrBase &d, std::error_code &e) noexcept
 Send bytes (a datagram) to a peer address, setting the error code. More...
 
size_t recv_next ()
 Return the number of bytes available to read (the size of the next datagram).
 
- Public Member Functions inherited from scc::net::SocketBase
 SocketBase (SocketBase &&other)
 Move construct socket.
 
const SocketBaseoperator= (SocketBase &&other)
 Move assign socket.
 
int fd () const
 Return the underlying socket handle.
 
 operator int () const
 Allow object to be cast to a socket handle.
 
void reuse_addr (bool r=true)
 Set address reusable. More...
 
void reuse_port (bool r=true)
 Set port reusable. More...
 
void non_blocking (bool b=true)
 Set the socket non-blocking. More...
 
std::error_code error_code ()
 Get the current error code (status). More...
 
void recv_bufsize (unsigned)
 Set receive buffer size. More...
 
unsigned recv_bufsize ()
 Get total receive buffer size including overhead.
 
void send_bufsize (unsigned)
 Set send buffer size. More...
 
unsigned send_bufsize ()
 Get total send buffer size including overhead.
 
void send_timeout (std::chrono::milliseconds)
 Set the send timeout. More...
 
void recv_timeout (std::chrono::milliseconds)
 Set the receive timeout. More...
 
void bind (const SockaddrBase &)
 Bind an address to the socket.
 
size_t recv (void *loc, size_t len)
 Receive bytes, throwing an exception on error. More...
 
size_t recv (void *loc, size_t len, std::error_code &e) noexcept
 Receive bytes. More...
 
size_t send (const void *loc, size_t len)
 Send bytes, throwing an exception on error. More...
 
size_t send (const void *loc, size_t len, std::error_code &e) noexcept
 Send bytes, setting the error code for the call. More...
 
void close ()
 Close the socket.
 

Additional Inherited Members

- Protected Member Functions inherited from scc::net::UdpSocket
 UdpSocket (int, int, int)
 
- Protected Member Functions inherited from scc::net::SocketBase
 SocketBase (int fd)
 
 SocketBase (int, int, int)
 
void reset (int, int, int)
 
void move (SocketBase &other)
 
void get_sockaddr (sockaddr &)
 

Detailed Description

Internet user datagram protocol (udp) socket.

Allows connectionless delivery of messages (datagrams), with a checksum for message integrity, but no guarantee of message ordering or delivery.

Examples
examples/net/netmain.cc, and net/unittest/inet.cc.

Definition at line 294 of file inet.h.

Member Function Documentation

◆ mcast_hops()

void InetUdpSock::mcast_hops ( unsigned  hops = 1)

Hop limit for outgoing multicast messages.

This is number of times the message will be passed between routers for outgoing traffic.

The default is 1 (the local subnet router only).

Definition at line 556 of file inet.cc.

◆ mcast_interface()

void InetUdpSock::mcast_interface ( unsigned  interface = 0)

Set the default interface for outgoing multicast messages.

Sets the default interface index.

See also
net::Interfaces

If interface is 0, removes the default (and lets the system choose an interface).

Definition at line 530 of file inet.cc.

◆ mcast_join_group()

void InetUdpSock::mcast_join_group ( const InetAddr group_addr,
unsigned  interface = 0 
)

Join a multicast group.

Joins a group on the network interface.

See also
net::Interfaces

All-nodes groups (e.g. ff01::1 and ff02::1) are automatically joined.

ipv4 mapped multicast addresses are not supported.

Definition at line 496 of file inet.cc.

◆ mcast_loopback()

void InetUdpSock::mcast_loopback ( bool  loop = true)

Enable or disable multicast loopback.

If enabled, multicast messages sent by the interface will be recieved on the interface.

Default is enabled.

Definition at line 543 of file inet.cc.


The documentation for this class was generated from the following files: