Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cUDPSendAfterLookup Class Reference

A hostname-to-IP resolver callback that sends the data stored within to the resolved IP address. More...

Inheritance diagram for cUDPSendAfterLookup:
Inheritance graph
[legend]
Collaboration diagram for cUDPSendAfterLookup:
Collaboration graph
[legend]

Public Member Functions

 cUDPSendAfterLookup (const AString &a_Data, UInt16 a_Port, evutil_socket_t a_MainSock, evutil_socket_t a_SecondSock, bool a_IsMainSockIPv6)
 
- Public Member Functions inherited from cNetwork::cResolveNameCallbacks
virtual ~cResolveNameCallbacks ()
 

Protected Member Functions

virtual void OnError (int a_ErrorCode, const AString &a_ErrorMsg) override
 Called when an error is encountered while resolving. More...
 
virtual void OnFinished (void) override
 Called when all the addresses resolved have been reported via the OnNameResolved() callback. More...
 
virtual void OnNameResolved (const AString &a_Name, const AString &a_PI) override
 Called when the hostname is successfully resolved into an IP address. More...
 
virtual bool OnNameResolvedV4 (const AString &a_Name, const sockaddr_in *a_IP) override
 Called when the hostname is successfully resolved into an IPv4 address. More...
 
virtual bool OnNameResolvedV6 (const AString &a_Name, const sockaddr_in6 *a_IP) override
 Called when the hostname is successfully resolved into an IPv6 address. More...
 

Protected Attributes

sockaddr_in m_AddrIPv4
 The IPv4 address resolved, if any. More...
 
sockaddr_in6 m_AddrIPv6
 The IPv6 address resolved, if any. More...
 
AString m_Data
 The data to send after the hostname is resolved. More...
 
bool m_HasIPv4
 Set to true if the name resolved to an IPv4 address. More...
 
bool m_HasIPv6
 Set to true if the name resolved to an IPv6 address. More...
 
bool m_IsMainSockIPv6
 True if m_MainSock is an IPv6 socket. More...
 
evutil_socket_t m_MainSock
 The primary socket to use for sending. More...
 
UInt16 m_Port
 The port to which to send the data. More...
 
evutil_socket_t m_SecondSock
 The secondary socket to use for sending, if needed by the OS. More...
 

Detailed Description

A hostname-to-IP resolver callback that sends the data stored within to the resolved IP address.

This is used for sending UDP datagrams to hostnames, so that the cUDPEndpoint::Send() doesn't block. Instead an instance of this callback is queued for resolving and the data is sent once the IP is resolved.

Definition at line 57 of file UDPEndpointImpl.cpp.

Constructor & Destructor Documentation

◆ cUDPSendAfterLookup()

cUDPSendAfterLookup::cUDPSendAfterLookup ( const AString a_Data,
UInt16  a_Port,
evutil_socket_t  a_MainSock,
evutil_socket_t  a_SecondSock,
bool  a_IsMainSockIPv6 
)
inline

Definition at line 61 of file UDPEndpointImpl.cpp.

Member Function Documentation

◆ OnError()

virtual void cUDPSendAfterLookup::OnError ( int  a_ErrorCode,
const AString a_ErrorMsg 
)
inlineoverrideprotectedvirtual

Called when an error is encountered while resolving.

If an error is reported, the OnFinished() callback is not called.

Implements cNetwork::cResolveNameCallbacks.

Definition at line 174 of file UDPEndpointImpl.cpp.

◆ OnFinished()

virtual void cUDPSendAfterLookup::OnFinished ( void  )
inlineoverrideprotectedvirtual

Called when all the addresses resolved have been reported via the OnNameResolved() callback.

Only called if there was no error reported.

Implements cNetwork::cResolveNameCallbacks.

Definition at line 133 of file UDPEndpointImpl.cpp.

◆ OnNameResolved()

virtual void cUDPSendAfterLookup::OnNameResolved ( const AString a_Name,
const AString a_IP 
)
inlineoverrideprotectedvirtual

Called when the hostname is successfully resolved into an IP address.

May be called multiple times if a name resolves to multiple addresses. a_IP may be either an IPv4 or an IPv6 address with their proper formatting. Each call to OnNameResolved() is preceded by a call to either OnNameResolvedV4() or OnNameResolvedV6().

Implements cNetwork::cResolveNameCallbacks.

Definition at line 102 of file UDPEndpointImpl.cpp.

◆ OnNameResolvedV4()

virtual bool cUDPSendAfterLookup::OnNameResolvedV4 ( const AString a_Name,
const sockaddr_in *  a_IP 
)
inlineoverrideprotectedvirtual

Called when the hostname is successfully resolved into an IPv4 address.

May be called multiple times if a name resolves to multiple addresses. Each call to OnNameResolvedV4 is followed by OnNameResolved with the IP address serialized to a string. If this callback returns false, the OnNameResolved() call is skipped for this address.

Reimplemented from cNetwork::cResolveNameCallbacks.

Definition at line 107 of file UDPEndpointImpl.cpp.

◆ OnNameResolvedV6()

virtual bool cUDPSendAfterLookup::OnNameResolvedV6 ( const AString a_Name,
const sockaddr_in6 *  a_IP 
)
inlineoverrideprotectedvirtual

Called when the hostname is successfully resolved into an IPv6 address.

May be called multiple times if a name resolves to multiple addresses. Each call to OnNameResolvedV4 is followed by OnNameResolved with the IP address serialized to a string. If this callback returns false, the OnNameResolved() call is skipped for this address.

Reimplemented from cNetwork::cResolveNameCallbacks.

Definition at line 120 of file UDPEndpointImpl.cpp.

Member Data Documentation

◆ m_AddrIPv4

sockaddr_in cUDPSendAfterLookup::m_AddrIPv4
protected

The IPv4 address resolved, if any.

Definition at line 89 of file UDPEndpointImpl.cpp.

◆ m_AddrIPv6

sockaddr_in6 cUDPSendAfterLookup::m_AddrIPv6
protected

The IPv6 address resolved, if any.

Definition at line 95 of file UDPEndpointImpl.cpp.

◆ m_Data

AString cUDPSendAfterLookup::m_Data
protected

The data to send after the hostname is resolved.

Definition at line 74 of file UDPEndpointImpl.cpp.

◆ m_HasIPv4

bool cUDPSendAfterLookup::m_HasIPv4
protected

Set to true if the name resolved to an IPv4 address.

Definition at line 92 of file UDPEndpointImpl.cpp.

◆ m_HasIPv6

bool cUDPSendAfterLookup::m_HasIPv6
protected

Set to true if the name resolved to an IPv6 address.

Definition at line 98 of file UDPEndpointImpl.cpp.

◆ m_IsMainSockIPv6

bool cUDPSendAfterLookup::m_IsMainSockIPv6
protected

True if m_MainSock is an IPv6 socket.

Definition at line 86 of file UDPEndpointImpl.cpp.

◆ m_MainSock

evutil_socket_t cUDPSendAfterLookup::m_MainSock
protected

The primary socket to use for sending.

Definition at line 80 of file UDPEndpointImpl.cpp.

◆ m_Port

UInt16 cUDPSendAfterLookup::m_Port
protected

The port to which to send the data.

Definition at line 77 of file UDPEndpointImpl.cpp.

◆ m_SecondSock

evutil_socket_t cUDPSendAfterLookup::m_SecondSock
protected

The secondary socket to use for sending, if needed by the OS.

Definition at line 83 of file UDPEndpointImpl.cpp.


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