folly::AsyncUDPServerSocket

UDP server socket

Synopsis

Declared in <folly/io/async/AsyncUDPServerSocket.h>

class AsyncUDPServerSocket
    : public AsyncSocketBase

Description

It wraps a UDP socket waiting for packets and distributes them among a set of event loops in round robin fashion.

NOTE: At the moment it is designed to work with single packet protocols in mind. We distribute incoming packets among all the listeners in round-robin fashion. So, any protocol that expects to send/recv more than 1 packet will not work because they will end up with different event base to process.

Base Classes

NameDescription
AsyncSocketBaseBase interface for asynchronous sockets bound to an event base.

Types

NameDescription
Callback Receives lifecycle and data events from the server socket.

Enums

NameDescription
DispatchMechanism Strategy used to pick which listener handles each incoming packet.

Member Functions

NameDescription
AsyncUDPServerSocket [constructor]Create a new UDP server socket
~AsyncUDPServerSocket [destructor] [virtual]Destroys the server socket, closing it if still open.
addListener Add a listener to the round robin list
address Returns the local address the socket is bound to.
bind Binds the underlying socket to a local address.
close Closes the underlying socket and releases it.
getAddress [virtual]Writes the local address into the given output parameter.
getEventBase [virtual]Returns the event base that drives this server socket.
getNetworkSocket Returns the underlying network socket handle.
getSocket Returns the underlying UDP socket.
isAccepting Indicates if the current socket is accepting.
listen Starts reading packets and notifies all registered listeners.
pauseAccepting Pauses accepting datagrams on the underlying socket.
pauseAcceptingNewPeer Inform the callback object that it should not process read from new client address.
resumeAccepting Starts accepting datagrams once again.
resumeAcceptingNewPeer Inform the callback object that it can process read from new client address now.
setRecvTos Enables or disables receiving the type-of-service field.
setReuseAddr Enables or disables address reuse before binding.
setReusePort Enables or disables port reuse before binding.
setTimestamping Enables socket timestamping options.
setTosOrTrafficClass Sets the type-of-service or traffic class on the socket.