Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <UDPEndpointImpl.h>
Public Member Functions | |
virtual void | Close (void) override |
Closes the underlying socket. More... | |
cUDPEndpointImpl (UInt16 a_Port, cUDPEndpoint::cCallbacks &a_Callbacks) | |
Creates a new instance of the endpoint, with the specified callbacks. More... | |
virtual void | EnableBroadcasts (void) override |
Marks the socket as capable of sending broadcast, using whatever OS API is needed. More... | |
virtual UInt16 | GetPort (void) const override |
Returns the local port to which the underlying socket is bound. More... | |
virtual bool | IsOpen (void) const override |
Returns true if the endpoint is open. More... | |
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. More... | |
virtual | ~cUDPEndpointImpl () override |
Public Member Functions inherited from cUDPEndpoint | |
virtual | ~cUDPEndpoint () |
Protected Member Functions | |
void | Callback (evutil_socket_t a_Socket, short a_What) |
The callback that is called when an event occurs on one of the sockets. More... | |
void | Open (UInt16 a_Port) |
Creates and opens the socket on the specified port. More... | |
Protected Member Functions inherited from cUDPEndpoint | |
cUDPEndpoint (cCallbacks &a_Callbacks) | |
Creates a new instance of an endpoint, with the specified callbacks. More... | |
Static Protected Member Functions | |
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. More... | |
Protected Attributes | |
bool | m_IsMainSockIPv6 |
True if m_MainSock is in the IPv6 namespace (needs IPv6 addresses for sending). More... | |
event * | m_MainEvent |
The LibEvent handle for the primary socket. More... | |
evutil_socket_t | m_MainSock |
The primary underlying OS socket. More... | |
UInt16 | m_Port |
The local port on which the endpoint is open. More... | |
event * | m_SecondaryEvent |
The LibEvent handle for the secondary socket. More... | |
evutil_socket_t | m_SecondarySock |
The secondary OS socket (if primary doesn't support dualstack). More... | |
Protected Attributes inherited from cUDPEndpoint | |
cCallbacks & | m_Callbacks |
The callbacks used for various events on the endpoint. More... | |
Private Types | |
using | Super = cUDPEndpoint |
Definition at line 27 of file UDPEndpointImpl.h.
|
private |
Definition at line 30 of file UDPEndpointImpl.h.
cUDPEndpointImpl::cUDPEndpointImpl | ( | UInt16 | a_Port, |
cUDPEndpoint::cCallbacks & | a_Callbacks | ||
) |
Creates a new instance of the endpoint, with the specified callbacks.
Tries to open on the specified port; if it fails, the endpoint is left in the "closed" state. If a_Port is 0, the OS is free to assign any port number it likes to the endpoint.
Definition at line 187 of file UDPEndpointImpl.cpp.
|
overridevirtual |
Definition at line 203 of file UDPEndpointImpl.cpp.
|
protected |
The callback that is called when an event occurs on one of the sockets.
Definition at line 571 of file UDPEndpointImpl.cpp.
|
overridevirtual |
Closes the underlying socket.
Note that there still might be callbacks in-flight after this method returns.
Implements cUDPEndpoint.
Definition at line 212 of file UDPEndpointImpl.cpp.
|
overridevirtual |
Marks the socket as capable of sending broadcast, using whatever OS API is needed.
Without this call, sending to a broadcast address using Send() may fail.
Implements cUDPEndpoint.
Definition at line 326 of file UDPEndpointImpl.cpp.
|
overridevirtual |
Returns the local port to which the underlying socket is bound.
Implements cUDPEndpoint.
Definition at line 255 of file UDPEndpointImpl.cpp.
|
overridevirtual |
Returns true if the endpoint is open.
Implements cUDPEndpoint.
Definition at line 246 of file UDPEndpointImpl.cpp.
|
protected |
Creates and opens the socket on the specified port.
If a_Port is 0, the OS is free to assign any port number it likes to the endpoint. If the opening fails, the OnError() callback is called and the endpoint is left "closed" (IsOpen() returns false).
Definition at line 371 of file UDPEndpointImpl.cpp.
|
staticprotected |
The callback that LibEvent calls when an event occurs on one of the sockets.
Calls Callback() on a_Self.
Definition at line 561 of file UDPEndpointImpl.cpp.
|
overridevirtual |
Sends the specified payload in a single UDP datagram to the specified host + port combination.
Note that in order to send to a broadcast address, you need to call EnableBroadcasts() first.
Implements cUDPEndpoint.
Definition at line 264 of file UDPEndpointImpl.cpp.
|
protected |
True if m_MainSock is in the IPv6 namespace (needs IPv6 addresses for sending).
Definition at line 57 of file UDPEndpointImpl.h.
|
protected |
The LibEvent handle for the primary socket.
Definition at line 63 of file UDPEndpointImpl.h.
|
protected |
The primary underlying OS socket.
Definition at line 54 of file UDPEndpointImpl.h.
|
protected |
The local port on which the endpoint is open.
If this is zero, it means the endpoint is closed - either opening has failed, or it has been closed explicitly.
Definition at line 51 of file UDPEndpointImpl.h.
|
protected |
The LibEvent handle for the secondary socket.
Definition at line 66 of file UDPEndpointImpl.h.
|
protected |
The secondary OS socket (if primary doesn't support dualstack).
Definition at line 60 of file UDPEndpointImpl.h.