Cuberite
A lightweight, fast and extensible game server for Minecraft
Classes | Public Types | Static Public Member Functions | List of all members
cNetwork Class Reference

#include <Network.h>

Classes

class  cConnectCallbacks
 Callbacks used for connecting to other servers as a client. More...
 
class  cListenCallbacks
 Callbacks used when listening for incoming connections as a server. More...
 
class  cResolveNameCallbacks
 Callbacks used when resolving names to IPs. More...
 

Public Types

typedef std::shared_ptr< cConnectCallbackscConnectCallbacksPtr
 
typedef std::shared_ptr< cListenCallbackscListenCallbacksPtr
 
typedef std::shared_ptr< cResolveNameCallbackscResolveNameCallbacksPtr
 

Static Public Member Functions

static bool Connect (const AString &a_Host, UInt16 a_Port, cConnectCallbacksPtr a_ConnectCallbacks, cTCPLink::cCallbacksPtr a_LinkCallbacks)
 Queues a TCP connection to be made to the specified host. More...
 
static cUDPEndpointPtr CreateUDPEndpoint (UInt16 a_Port, cUDPEndpoint::cCallbacks &a_Callbacks)
 Opens up an UDP endpoint for sending and receiving UDP datagrams on the specified port. More...
 
static AStringVector EnumLocalIPAddresses (void)
 Returns all local IP addresses for network interfaces currently available. More...
 
static bool HostnameToIP (const AString &a_Hostname, cResolveNameCallbacksPtr a_Callbacks)
 Queues a DNS query to resolve the specified hostname to IP address. More...
 
static bool IPToHostName (const AString &a_IP, cResolveNameCallbacksPtr a_Callbacks)
 Queues a DNS query to resolve the specified IP address to a hostname. More...
 
static cServerHandlePtr Listen (UInt16 a_Port, cListenCallbacksPtr a_ListenCallbacks)
 Opens up the specified port for incoming connections. More...
 

Detailed Description

Definition at line 232 of file Network.h.

Member Typedef Documentation

◆ cConnectCallbacksPtr

Definition at line 249 of file Network.h.

◆ cListenCallbacksPtr

Definition at line 273 of file Network.h.

◆ cResolveNameCallbacksPtr

Definition at line 309 of file Network.h.

Member Function Documentation

◆ Connect()

bool cNetwork::Connect ( const AString a_Host,
UInt16  a_Port,
cNetwork::cConnectCallbacksPtr  a_ConnectCallbacks,
cTCPLink::cCallbacksPtr  a_LinkCallbacks 
)
static

Queues a TCP connection to be made to the specified host.

Calls one the connection callbacks (success, error) when the connection is successfully established, or upon failure. The a_LinkCallbacks is passed to the newly created cTCPLink. Returns true if queueing was successful, false on failure to queue. Note that the return value doesn't report the success of the actual connection; the connection is established asynchronously in the background. Implemented in TCPLinkImpl.cpp.

Definition at line 719 of file TCPLinkImpl.cpp.

◆ CreateUDPEndpoint()

cUDPEndpointPtr cNetwork::CreateUDPEndpoint ( UInt16  a_Port,
cUDPEndpoint::cCallbacks a_Callbacks 
)
static

Opens up an UDP endpoint for sending and receiving UDP datagrams on the specified port.

If a_Port is 0, the OS is free to assign any port number it likes to the endpoint. Returns the endpoint object that can be interacted with.

Definition at line 620 of file UDPEndpointImpl.cpp.

◆ EnumLocalIPAddresses()

AStringVector cNetwork::EnumLocalIPAddresses ( void  )
static

Returns all local IP addresses for network interfaces currently available.

Definition at line 91 of file NetworkInterfaceEnum.cpp.

◆ HostnameToIP()

bool cNetwork::HostnameToIP ( const AString a_Hostname,
cNetwork::cResolveNameCallbacksPtr  a_Callbacks 
)
static

Queues a DNS query to resolve the specified hostname to IP address.

Calls one of the callbacks when the resolving succeeds, or when it fails. Returns true if queueing was successful, false if not. Note that the return value doesn't report the success of the actual lookup; the lookup happens asynchronously on the background. Implemented in HostnameLookup.cpp.

Definition at line 125 of file HostnameLookup.cpp.

◆ IPToHostName()

bool cNetwork::IPToHostName ( const AString a_IP,
cNetwork::cResolveNameCallbacksPtr  a_Callbacks 
)
static

Queues a DNS query to resolve the specified IP address to a hostname.

Calls one of the callbacks when the resolving succeeds, or when it fails. Returns true if queueing was successful, false if not. Note that the return value doesn't report the success of the actual lookup; the lookup happens asynchronously on the background. Implemented in IPLookup.cpp.

Definition at line 91 of file IPLookup.cpp.

◆ Listen()

cServerHandlePtr cNetwork::Listen ( UInt16  a_Port,
cNetwork::cListenCallbacksPtr  a_ListenCallbacks 
)
static

Opens up the specified port for incoming connections.

Calls an OnAccepted callback for each incoming connection. A cTCPLink with the specified link callbacks is created for each connection. Returns a cServerHandle that can be used to query the operation status and close the server. Implemented in ServerHandleImpl.cpp.

Definition at line 371 of file ServerHandleImpl.cpp.


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