13 #include <event2/event.h>
42 virtual void Close(
void)
override;
43 virtual bool IsOpen(
void)
const override;
76 static void RawCallback(evutil_socket_t a_Socket,
short a_What,
void * a_Self);
79 void Callback(evutil_socket_t a_Socket,
short a_What);
std::shared_ptr< cUDPEndpointImpl > cUDPEndpointImplPtr
Interface that provides methods available on UDP communication endpoints.
cUDPEndpoint(cCallbacks &a_Callbacks)
Creates a new instance of an endpoint, with the specified callbacks.
Interface for the callbacks for events that can happen on the endpoint.
evutil_socket_t m_MainSock
The primary underlying OS socket.
virtual UInt16 GetPort(void) const override
Returns the local port to which the underlying socket is bound.
evutil_socket_t m_SecondarySock
The secondary OS socket (if primary doesn't support dualstack).
virtual void Close(void) override
Closes the underlying socket.
void Callback(evutil_socket_t a_Socket, short a_What)
The callback that is called when an event occurs on one of the sockets.
virtual ~cUDPEndpointImpl() override
virtual bool Send(const AString &a_Payload, const AString &a_Host, UInt16 a_Port) override
Sends the specified payload in a single UDP datagram to the specified host + port combination.
virtual bool IsOpen(void) const override
Returns true if the endpoint is open.
event * m_SecondaryEvent
The LibEvent handle for the secondary socket.
virtual void EnableBroadcasts(void) override
Marks the socket as capable of sending broadcast, using whatever OS API is needed.
UInt16 m_Port
The local port on which the endpoint is open.
static void RawCallback(evutil_socket_t a_Socket, short a_What, void *a_Self)
The callback that LibEvent calls when an event occurs on one of the sockets.
bool m_IsMainSockIPv6
True if m_MainSock is in the IPv6 namespace (needs IPv6 addresses for sending).
void Open(UInt16 a_Port)
Creates and opens the socket on the specified port.
event * m_MainEvent
The LibEvent handle for the primary socket.
cUDPEndpointImpl(UInt16 a_Port, cUDPEndpoint::cCallbacks &a_Callbacks)
Creates a new instance of the endpoint, with the specified callbacks.