libclod
C library for interacting with NBTs, region files, LOD data and other things.
Loading...
Searching...
No Matches
net.h File Reference

Networking. More...

#include <clod/lib.h>
#include <clod/stream.h>

Go to the source code of this file.

Classes

struct  clod_socket

Macros

#define clod_ipv4(a, b, c, d)
 Helper for crating IPv4-mapped IPv6 address.

Typedefs

typedef struct clod_socker clod_socket

Functions

int clod_udp (clod_socket *socket, int flags)
int clod_tcp_client (clod_socket *socket, int flags)
int clod_tcp_server (clod_socket *socket, int flags)

Detailed Description

Networking.

Methods for TCP and UDP connections using libclod's stream API. IPv4 is also supported - just use an IPv4-mapped IPv6 address; bytes 0-10 = 0, byte 11 = 0xFF, bytes 12-15 = IPv4 address.

Definition in file net.h.

Macro Definition Documentation

◆ clod_ipv4

#define clod_ipv4 ( a,
b,
c,
d )
Value:
((char[16]){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, a, b, c, d})

Helper for crating IPv4-mapped IPv6 address.

Definition at line 18 of file net.h.

Typedef Documentation

◆ clod_socket

typedef struct clod_socker clod_socket

Definition at line 15 of file net.h.

Function Documentation

◆ clod_udp()

int clod_udp ( clod_socket * socket,
int flags )

Initialise a UDP socket for reading and writing.

Parameters
[in,out]socketNew TCP socket.
[in]flagsConfiguration flags.
Returns
0 on success, non-zero on error.

◆ clod_tcp_client()

int clod_tcp_client ( clod_socket * socket,
int flags )

Initialise a TCP client-side socket for reading and writing. Upon a successful connection, the stream transfers bytes between

Parameters
[in,out]socketNew TCP socket.
[in]flagsConfiguration flags.
Returns
0 on success, non-zero on error.

◆ clod_tcp_server()

int clod_tcp_server ( clod_socket * socket,
int flags )

Initialise a TCP

Parameters
[in,out]socketNew TCP socket.
[in]flagsConfiguration flags.
Returns
0 on success, non-zero on error.