XPMP2
X-Plane multiplayer library 2 - using instancing
XPMP2::UDPReceiver Class Reference

Receives UDP messages. More...

#include <Network.h>

+ Inheritance diagram for XPMP2::UDPReceiver:

Public Member Functions

 UDPReceiver ()
 Default constructor is not doing anything.
 
- Public Member Functions inherited from XPMP2::SocketNetworking
 SocketNetworking ()
 Default constructor is not doing anything.
 
virtual ~SocketNetworking ()
 Destructor makes sure the socket is closed.
 
virtual void Open (const std::string &_addr, int _port, size_t _bufSize=512, unsigned _timeOut_ms=0, bool _bBroadcast=false)
 Creates a socket and binds it to the given local address.
 
virtual void Connect (const std::string &_addr, int _port, size_t _bufSize, unsigned _timeOut_ms=0)
 Creates a socket and connects it to the given remote server.
 
virtual void Close ()
 Thread-safely close the connection(s) and frees the buffer.
 
bool isOpen () const
 Is a socket open?
 
void SetBufSize (size_t _bufSize)
 (Re)Sets the buffer size (or clears it if _bufSize==0)
 
SOCKET getSocket () const
 the socket
 
int getPort () const
 the port
 
std::string getAddr () const
 the interface address
 
const char * getBuf () const
 return the buffer
 
void setBlocking (bool bBlock)
 Set blocking mode.
 
long recv (std::string *_pFromAddr=nullptr, SockAddrTy *_pFromSockAddr=nullptr)
 Waits to receive a message, ensures zero-termination in the buffer.
 
long timedRecv (int max_wait_ms, std::string *_pFromAddr=nullptr, SockAddrTy *_pFromSockAddr=nullptr)
 Waits to receive a message with timeout, ensures zero-termination in the buffer.
 
virtual bool send (const char *msg)
 send messages on session connection
 
bool broadcast (const char *msg)
 Sends a broadcast message.
 

Protected Member Functions

void GetAddrHints (struct addrinfo &hints) override
 Sets flags to AI_PASSIVE, AF_INET, SOCK_DGRAM, IPPROTO_UDP.
 
- Protected Member Functions inherited from XPMP2::SocketNetworking

Additional Inherited Members

- Static Public Member Functions inherited from XPMP2::SocketNetworking
static std::string GetLastErr ()
 Returns a human-readable text for the last error.
 
static std::string GetAddrString (const SockAddrTy &sa, bool withPort=true)
 Convert addresses to string.
 
- Protected Attributes inherited from XPMP2::SocketNetworking
SOCKET f_socket = INVALID_SOCKET
 
int f_port = 0
 
std::string f_addr
 
char * buf = NULL
 
size_t bufSize = 512
 

Detailed Description

Receives UDP messages.

Constructor & Destructor Documentation

◆ UDPReceiver()

XPMP2::UDPReceiver::UDPReceiver ( )
inline

Default constructor is not doing anything.

Member Function Documentation

◆ GetAddrHints()

void XPMP2::UDPReceiver::GetAddrHints ( struct addrinfo & hints)
overrideprotectedvirtual

Sets flags to AI_PASSIVE, AF_INET, SOCK_DGRAM, IPPROTO_UDP.

Implements XPMP2::SocketNetworking.


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