Function in stdx_network.h

x_net_accept

Accept an incoming connection on a listening socket.

XSocket x_net_accept(
 XSocket sock,
 XAddress *out_addr
);

Parameters

XSocket sock
Listening socket handle.
XAddress *out_addr
Optional output address receiving the peer address (may be NULL if supported).

Returns

New connected socket handle, or an invalid socket value on failure.

Function in stdx_network.h

x_net_bind

Bind a socket to a specific local address.

bool x_net_bind(
 XSocket sock,
 const XAddress *addr
);

Parameters

XSocket sock
Socket handle to bind.
const XAddress *addr
Local address to bind to.

Returns

True on success, false on failure.

Function in stdx_network.h

x_net_bind_any

Bind a socket to any local address of the given family and port.

bool x_net_bind_any(
 XSocket sock,
 XAddressFamily family,
 uint16_t port
);

Parameters

XSocket sock
Socket handle to bind.
XAddressFamily family
Address family to bind (e.g., IPv4/IPv6).
uint16_t port
Local port to bind to.

Returns

True on success, false on failure.

Function in stdx_network.h

x_net_connect

Connect a socket to a remote address.

int32_t x_net_connect(
 XSocket sock,
 const XAddress *addr
);

Parameters

XSocket sock
Socket handle to connect.
const XAddress *addr
Remote address to connect to.

Returns

0 on success, -1 on error, or a platform-defined in-progress code for non-blocking sockets.

Function in stdx_network.h

x_net_enable_broadcast

Enable or disable broadcast capability on a socket.

bool x_net_enable_broadcast(
 XSocket sock,
 bool enable
);

Parameters

XSocket sock
Socket handle.
bool enable
True to enable broadcast, false to disable.

Returns

True on success, false on failure.

Function in stdx_network.h

x_net_get_last_error

Get the last network error code for the current thread/process.

int32_t x_net_get_last_error(void);

Returns

Last error code (WSAGetLastError() on Windows, errno on POSIX).

Function in stdx_network.h

x_net_get_last_error_message

Write a human-readable message for the last network error into a buffer.

int32_t x_net_get_last_error_message(
 char *buf,
 int32_t buf_len
);

Parameters

char *buf
Output buffer to receive the message string.
int32_t buf_len
Size of buf in bytes/chars.

Returns

0 on success, or -1 on failure (e.g., buffer too small).

Function in stdx_network.h

x_net_listen

Mark a bound socket as listening for incoming connections.

bool x_net_listen(
 XSocket sock,
 int32_t backlog
);

Parameters

XSocket sock
Socket handle.
int32_t backlog
Maximum pending connection queue length.

Returns

True on success, false on failure.