XPMP2
X-Plane multiplayer library 2 - using instancing
Public Member Functions | Protected Member Functions | List of all members
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. More...
 
- Public Member Functions inherited from XPMP2::SocketNetworking
 SocketNetworking ()
 Default constructor is not doing anything. More...
 
virtual ~SocketNetworking ()
 Destructor makes sure the socket is closed. More...
 
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. More...
 
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. More...
 
virtual void Close ()
 Thread-safely close the connection(s) and frees the buffer. More...
 
bool isOpen () const
 Is a socket open? More...
 
void SetBufSize (size_t _bufSize)
 (Re)Sets the buffer size (or clears it if _bufSize==0) More...
 
SOCKET getSocket () const
 the socket More...
 
int getPort () const
 the port More...
 
std::string getAddr () const
 the interface address More...
 
const char * getBuf () const
 return the buffer More...
 
void setBlocking (bool bBlock)
 Set blocking mode. More...
 
long recv (std::string *_pFromAddr=nullptr, SockAddrTy *_pFromSockAddr=nullptr)
 Waits to receive a message, ensures zero-termination in the buffer. More...
 
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. More...
 
virtual bool send (const char *msg)
 send messages on session connection More...
 
bool broadcast (const char *msg)
 Sends a broadcast message. More...
 

Protected Member Functions

void GetAddrHints (struct addrinfo &hints) override
 Sets flags to AI_PASSIVE, AF_INET, SOCK_DGRAM, IPPROTO_UDP. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from XPMP2::SocketNetworking
static std::string GetLastErr ()
 Returns a human-readable text for the last error. More...
 
static std::string GetAddrString (const SockAddrTy &sa, bool withPort=true)
 Convert addresses to string. More...
 
- 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: