XPMP2
X-Plane multiplayer library 2 - using instancing
Classes | Namespaces | Macros | Typedefs | Functions | Variables
Network.h File Reference

Low-level network communications, especially for TCP/UDP. More...

#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <ifaddrs.h>
#include <stdexcept>

Go to the source code of this file.

Classes

struct  XPMP2::SockAddrTy
 Helper definition for all these IPv4/6 differences. More...
 
class  XPMP2::NetRuntimeError
 Exception raised by XPMP2::SocketNetworking objects. More...
 
class  XPMP2::SocketNetworking
 Base class for any socket-based networking. More...
 
class  XPMP2::UDPReceiver
 Receives UDP messages. More...
 
class  XPMP2::UDPMulticast
 UDP Multicast, always binding to INADDR_ANY. More...
 
class  XPMP2::TCPConnection
 Listens to TCP connections and opens a session socket upon connect. More...
 
struct  XPMP2::InetAddrTy
 Numerical IP address, used for both ipv4 and ipv6, for ease of handling. More...
 
union  XPMP2::SockAddrTy.__unnamed4__
 
union  XPMP2::InetAddrTy.__unnamed6__
 

Namespaces

 XPMP2
 

Macros

#define __APPLE_USE_RFC_3542
 
#define _GNU_SOURCE
 

Typedefs

typedef int SOCKET
 Windows defines SOCKET, so we define it for non-Windows manually. More...
 

Functions

bool XPMP2::NetwIsLocalAddr (const InetAddrTy &addr)
 Is given address a local one? More...
 
bool XPMP2::NetwIsLocalAddr (const SockAddrTy &sa)
 Is given address a local one? More...
 
bool XPMP2::NetwIsLocalAddr (const sockaddr *pSa)
 Is given address a local one? More...
 
std::vector< std::string > XPMP2::NetwGetInterfaces (uint8_t family, uint32_t fMust=0, uint32_t fSkip=0)
 Return list of known local interfaces. More...
 
std::string XPMP2::NetwGetInterfaceNames (uint8_t family, uint32_t fMust=0, uint32_t fSkip=0)
 Return comma-separated string will all known local interfaces, calls NetwGetInterfaces() More...
 

Variables

constexpr SOCKET INVALID_SOCKET = -1
 

Detailed Description

Low-level network communications, especially for TCP/UDP.

See also
Some inital ideas and pieces of code take from https://linux.m2osw.com/c-implementation-udp-clientserver

XPMP2::SocketNetworking: Any network socket connection
XPMP2::UDPReceiver: listens to and receives UDP datagram
XPMP2::UDPMulticast: sends and receives multicast UDP datagrams
XPMP2::TCPConnection: receives incoming TCP connection

Author
Birger Hoppe

Class Documentation

◆ XPMP2::SockAddrTy.__unnamed4__

union XPMP2::SockAddrTy.__unnamed4__
Class Members
sockaddr sa
sockaddr_in sa_in
sockaddr_in6 sa_in6

◆ XPMP2::InetAddrTy.__unnamed6__

union XPMP2::InetAddrTy.__unnamed6__
Class Members
uint32_t addr[4]
struct in6_addr in6_addr
struct in_addr in_addr

Macro Definition Documentation

◆ __APPLE_USE_RFC_3542

#define __APPLE_USE_RFC_3542

◆ _GNU_SOURCE

#define _GNU_SOURCE

Typedef Documentation

◆ SOCKET

typedef int SOCKET

Windows defines SOCKET, so we define it for non-Windows manually.

Variable Documentation

◆ INVALID_SOCKET

constexpr SOCKET INVALID_SOCKET = -1
constexpr