DDNet documentation
Loading...
Searching...
No Matches
General

Classes

struct  NETSTATS

Typedefs

typedef struct NETSOCKET_INTERNALNETSOCKET
typedef struct NETSTATS NETSTATS

Functions

void net_init ()
int net_errno ()
std::string net_error_message ()
void net_stats (NETSTATS *stats)
int net_socket_type (NETSOCKET sock)
int net_set_non_blocking (NETSOCKET sock)
int net_set_blocking (NETSOCKET sock)
int net_would_block ()
int net_socket_read_wait (NETSOCKET sock, std::chrono::nanoseconds nanoseconds)

Variables

constexpr auto NETTYPE_INVALID = 0
constexpr auto NETTYPE_IPV4 = 1 << 0
constexpr auto NETTYPE_IPV6 = 1 << 1
constexpr auto NETTYPE_WEBSOCKET_IPV4 = 1 << 2
constexpr auto NETTYPE_WEBSOCKET_IPV6 = 1 << 3
constexpr auto NETTYPE_LINK_BROADCAST = 1 << 4
constexpr auto NETTYPE_TW7 = 1 << 5
constexpr auto NETTYPE_ALL = NETTYPE_IPV4 | NETTYPE_IPV6 | NETTYPE_WEBSOCKET_IPV4 | NETTYPE_WEBSOCKET_IPV6
constexpr auto NETTYPE_MASK = NETTYPE_ALL | NETTYPE_LINK_BROADCAST | NETTYPE_TW7

Detailed Description

Typedef Documentation

◆ NETSOCKET

typedef struct NETSOCKET_INTERNAL* NETSOCKET

◆ NETSTATS

typedef struct NETSTATS NETSTATS

Function Documentation

◆ net_errno()

int net_errno ( )

If a network operation failed, the error code.

Returns
The error code.

◆ net_error_message()

std::string net_error_message ( )

If a network operation failed, the platform-specific error code and string.

Returns
The error code and string combined into one string.

◆ net_init()

void net_init ( )

Initializes network functionality.

Remarks
You must call this function before using any other network functions.

◆ net_set_blocking()

int net_set_blocking ( NETSOCKET sock)

Make a socket block on operations.

Parameters
sockThe socket to set blocking mode on.
Returns
0 on success.

◆ net_set_non_blocking()

int net_set_non_blocking ( NETSOCKET sock)

Make a socket not block on operations.

Parameters
sockThe socket to set non-blocking mode on.
Returns
0 on success.

◆ net_socket_read_wait()

int net_socket_read_wait ( NETSOCKET sock,
std::chrono::nanoseconds nanoseconds )

Waits for a socket to have data available to receive up the specified timeout duration.

Parameters
sockSocket to wait on.
nanosecondsTimeout duration to wait.
Returns
1 if data was received within the timeout duration, 0 otherwise.

◆ net_socket_type()

int net_socket_type ( NETSOCKET sock)

Determine a socket's type.

Parameters
sockSocket whose type should be determined.
Returns
The socket type, a bitset of NETTYPE_IPV4, NETTYPE_IPV6, NETTYPE_WEBSOCKET_IPV4 and NETTYPE_WEBSOCKET_IPV6, or NETTYPE_INVALID if the socket is invalid.

◆ net_stats()

void net_stats ( NETSTATS * stats)

Retrieve network statistics.

Parameters
statsNetwork statistics to fill in.

◆ net_would_block()

int net_would_block ( )

Determines whether a network operation would block.

Returns
0 if wouldn't block, 1 if would block.

Variable Documentation

◆ NETTYPE_ALL

auto NETTYPE_ALL = NETTYPE_IPV4 | NETTYPE_IPV6 | NETTYPE_WEBSOCKET_IPV4 | NETTYPE_WEBSOCKET_IPV6
inlineconstexpr

◆ NETTYPE_INVALID

auto NETTYPE_INVALID = 0
inlineconstexpr

◆ NETTYPE_IPV4

auto NETTYPE_IPV4 = 1 << 0
inlineconstexpr

◆ NETTYPE_IPV6

auto NETTYPE_IPV6 = 1 << 1
inlineconstexpr

◆ NETTYPE_LINK_BROADCAST

auto NETTYPE_LINK_BROADCAST = 1 << 4
inlineconstexpr

◆ NETTYPE_MASK

auto NETTYPE_MASK = NETTYPE_ALL | NETTYPE_LINK_BROADCAST | NETTYPE_TW7
inlineconstexpr

◆ NETTYPE_TW7

auto NETTYPE_TW7 = 1 << 5
inlineconstexpr

0.7 address. This is a flag in NETADDR to avoid introducing a parameter to every networking function to differentiate between 0.6 and 0.7 connections.

◆ NETTYPE_WEBSOCKET_IPV4

auto NETTYPE_WEBSOCKET_IPV4 = 1 << 2
inlineconstexpr

◆ NETTYPE_WEBSOCKET_IPV6

auto NETTYPE_WEBSOCKET_IPV6 = 1 << 3
inlineconstexpr