GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::networking Namespace Reference

Classes

class  IPv4Address
 32-bit IP address of an IPv4 endpoint. More...
class  IPv6Address
 128-bit IP address of an IPv6 endpoint. More...
class  IPv4Endpoint
 Combined IPv4Address and PortNumber. More...
class  IPv6Endpoint
 Combined IPv6Address, PortNumber and ScopeID. More...
class  Endpoint
 Combined network address and port number (and potentially other info) that identifies a host, or set of hosts, on the network. More...
struct  Error
 Exception type for domain-specific errors originating from the grem::networking module. More...
struct  EndpointErrorCategory
 Error category type for error codes originating from the getaddrinfo() API. More...
struct  SocketErrorCategory
 Error category type for error codes originating from the Socket API. More...
class  Socket
 Generic socket handle/file descriptor for receiving and transmitting data across the network. More...
struct  UDPSocketOptions
 Configuration options for a UDPSocket. More...
class  UDPSocket
 Connectionless socket for receiving and transmitting unordered, unreliable datagrams across the network over ProtocolType::UDP. More...
struct  TCPSocketOptions
 Configuration options for a TCPSocket. More...
class  TCPSocket
 Connection-oriented socket for receiving and transmitting ordered, reliable streams of data across the network over ProtocolType::TCP. More...
struct  TCPListenerOptions
 Configuration options for a TCPListener. More...
class  TCPListener
 Listener socket for accepting incoming connections across the network over ProtocolType::TCP. More...

Typedefs

using PortNumber = uint16_t
 IP port number (0-65535).
using ScopeID = uint32_t
 IPv6 scope/zone ID.

Enumerations

enum class  AddressFamily : short { IPv4 = AF_INET , IPv6 = AF_INET6 }
 Address family of an IP endpoint. More...
enum class  EndpointError : int {
  AGAIN = EAI_AGAIN , BADFLAGS = EAI_BADFLAGS , FAIL = EAI_FAIL , FAMILY = EAI_FAMILY ,
  MEMORY = EAI_MEMORY , NODATA = EAI_NODATA , NONAME = EAI_NONAME , SERVICE = EAI_SERVICE ,
  SOCKTYPE = EAI_SOCKTYPE
}
 Error code value type for error codes originating from the getaddrinfo() API. More...
enum class  SocketError : int { WAIT = 1 , PARTIAL , DISCONNECTED , FAILED }
 Error condition type for error codes originating from the Socket API. More...
enum class  BlockingMode : uint8_t { UNSPECIFIED , BLOCKING , NON_BLOCKING }
 Blocking mode of a Socket. More...
enum class  ProtocolType : int { UDP = SOCK_DGRAM , TCP = SOCK_STREAM }
 Communication semantics of a Socket. More...
enum class  ShutdownType : int { RECEIVE = SD_RECEIVE , SEND = SD_SEND , BOTH = SD_BOTH }
 Direction(s) in which to shut down the connection of a Socket. More...
enum class  MessageFlags : int
 Strong type for a bitmask of native MSG_... flags. More...

Functions

std::error_code make_error_code (EndpointError error)
 Create a std::error_code from an EndpointError value.
std::error_code make_error_code (SocketError error)
 Create a std::error_code from a SocketError value.
std::error_condition make_error_condition (SocketError error)
 Create a std::error_condition from a SocketError value.
void ensurePlatformInitialized (std::error_code &errorCode)
 Initialize the underlying platform of the native socket API if it has not already been initialized.

Typedef Documentation

◆ PortNumber

using grem::networking::PortNumber = uint16_t

IP port number (0-65535).

Note
A value of 0 usually means "any port".

◆ ScopeID

using grem::networking::ScopeID = uint32_t

IPv6 scope/zone ID.

Enumeration Type Documentation

◆ AddressFamily

enum class grem::networking::AddressFamily : short
strong

Address family of an IP endpoint.

Enumerator
IPv4 

IPv4.

IPv6 

IPv6.

◆ EndpointError

enum class grem::networking::EndpointError : int
strong

Error code value type for error codes originating from the getaddrinfo() API.

Enumerator
AGAIN 

EAI_AGAIN.

BADFLAGS 

EAI_BADFLAGS.

FAIL 

EAI_FAIL.

FAMILY 

EAI_FAMILY.

MEMORY 

EAI_MEMORY.

NODATA 

EAI_NODATA.

NONAME 

EAI_NONAME.

SERVICE 

EAI_SERVICE.

SOCKTYPE 

EAI_SOCKTYPE.

◆ SocketError

enum class grem::networking::SocketError : int
strong

Error condition type for error codes originating from the Socket API.

Enumerator
WAIT 

Try again later.

PARTIAL 

The data was partially transmitted.

DISCONNECTED 

The socket disconnected.

FAILED 

The operation failed.

◆ BlockingMode

enum class grem::networking::BlockingMode : uint8_t
strong

Blocking mode of a Socket.

Enumerator
UNSPECIFIED 

Preserve current blocking mode.

BLOCKING 

Enable blocking.

NON_BLOCKING 

Disable blocking.

◆ ProtocolType

enum class grem::networking::ProtocolType : int
strong

Communication semantics of a Socket.

Enumerator
UDP 

User Datagram Protocol (connectionless, unreliable messages of a fixed maximum length).

TCP 

Transmission Control Protocol (connection-based, sequenced, reliable two-way data stream).

◆ ShutdownType

enum class grem::networking::ShutdownType : int
strong

Direction(s) in which to shut down the connection of a Socket.

Enumerator
RECEIVE 

Shut down further receptions.

SEND 

Shut down further transmissions.

BOTH 

Shut down both further receptions and transmissions.

◆ MessageFlags

enum class grem::networking::MessageFlags : int
strong

Strong type for a bitmask of native MSG_... flags.

Function Documentation

◆ make_error_code() [1/2]

std::error_code grem::networking::make_error_code ( EndpointError error)
inlinenodiscard

Create a std::error_code from an EndpointError value.

Parameters
errorerror code value to create the error code from.
Returns
the newly created std::error_code, with EndpointErrorCategory as its category.

◆ make_error_code() [2/2]

std::error_code grem::networking::make_error_code ( SocketError error)
inlinenodiscard

Create a std::error_code from a SocketError value.

Parameters
errorerror code value to create the error code from.
Returns
the newly created std::error_code, with SocketErrorCategory as its category.

◆ make_error_condition()

std::error_condition grem::networking::make_error_condition ( SocketError error)
inlinenodiscard

Create a std::error_condition from a SocketError value.

Parameters
errorerror condition value to create the error code from.
Returns
the newly created std::error_condition, with SocketErrorCategory as its category.

◆ ensurePlatformInitialized()

void grem::networking::ensurePlatformInitialized ( std::error_code & errorCode)

Initialize the underlying platform of the native socket API if it has not already been initialized.

Parameters
errorCodeerror code that is filled in on failure to initialize the platform, or cleared on success.
Note
If the platform was already initialized, the function will clear the error code, indicating success, and then immediately return.
The platform is automatically deinitialized when the program exits.
This function is used internally by the implementations of Endpoint and Socket, and does not need to be called manually in normal use of those APIs, but it may be useful when directly calling the native API functions exported by platform.hpp.