Typedefs | |
typedef enum net_recv_result_tag | net_recv_result_e |
typedef enum net_send_result_tag | net_send_result_e |
Enumerations | |
enum | net_recv_result_tag { NET_RECV_OK = 0, NET_RECV_AGAIN, NET_RECV_CLIENT_DISCONNECTED, NET_RECV_ERROR } |
enum | net_send_result_tag { NET_SEND_OK = 0, NET_SEND_AGAIN, NET_SEND_ERROR } |
Functions | |
bool | net_module_init (void) |
Initialise the network module. | |
void | net_module_close (void) |
Close the network module. | |
bool | net_socket_create (evutil_socket_t *sock) |
Create a new non-blocking IP streaming socket. | |
void | net_socket_close (evutil_socket_t sock) |
Gracefully close the given socket both ways. | |
bool | net_socket_accept (evutil_socket_t sock, evutil_socket_t *client) |
Accept on the given socket. | |
bool | net_socket_bind (evutil_socket_t sock, const unsigned short int port) |
Bind the specified socket to the given port. | |
bool | net_socket_listen (evutil_socket_t sock, int backlog) |
Start listening on the given socket. | |
net_recv_result_e | net_recv (evutil_socket_t sock, void *data, const size_t n, size_t *bytesRead) |
Receive data from the given socket. | |
net_send_result_e | net_send (evutil_socket_t sock, const void *data, const size_t n, size_t *bytesSent) |
Send data on the given socket. | |
bool | net_connect (evutil_socket_t *sock, const unsigned short int port) |
Connect to a given address. | |
bool | net_socket_make_nonblocking (evutil_socket_t sock) |
Make the given socket non-blocking. | |
h_uint16_t | net_ntohs (h_uint16_t netShort) |
Convert from network short to host short. |
typedef enum net_recv_result_tag net_recv_result_e |
typedef enum net_send_result_tag net_send_result_e |
enum net_recv_result_tag |
enum net_send_result_tag |
bool net_connect | ( | evutil_socket_t * | sock, | |
const unsigned short int | port | |||
) |
Connect to a given address.
sock | The socket to set once we've connected. | |
port | The port to connect on. |
void net_module_close | ( | void | ) |
Close the network module.
bool net_module_init | ( | void | ) |
Initialise the network module.
Call before using any other net_ functions.
true
on success. On error, false
is returned h_uint16_t net_ntohs | ( | h_uint16_t | netShort | ) |
Convert from network short to host short.
netShort | The network short to convert to host short byte order. |
net_recv_result_e net_recv | ( | evutil_socket_t | sock, | |
void * | data, | |||
const size_t | n, | |||
size_t * | bytesRead | |||
) |
Receive data from the given socket.
sock | The connected socket to receive on. | |
data | Where to put the bytes. | |
n | The number of bytes to read. | |
bytesRead | Where to put the number of bytes read. |
net_send_result_e net_send | ( | evutil_socket_t | sock, | |
const void * | data, | |||
const size_t | n, | |||
size_t * | bytesSent | |||
) |
Send data on the given socket.
sock | The connected socket to send on. | |
data | Where to get the bytes. | |
n | The number of bytes to send. | |
bytesSent | Where to put the number of bytes sent. |
bool net_socket_accept | ( | evutil_socket_t | sock, | |
evutil_socket_t * | client | |||
) |
Accept on the given socket.
sock | The socket to accept on. | |
client | The socket that was accepted if true is returned. Should be closed when you're finished. The socket is non-blocking. |
true
if we've accepted a socket into newSock. On error, false
is returned. bool net_socket_bind | ( | evutil_socket_t | sock, | |
const unsigned short int | port | |||
) |
Bind the specified socket to the given port.
sock | The socket to bind. | |
port | The port to bind to. |
true
if we're now bound. On error, false
is returned. void net_socket_close | ( | evutil_socket_t | sock | ) |
Gracefully close the given socket both ways.
sock | The address of the socket to close. |
bool net_socket_create | ( | evutil_socket_t * | sock | ) |
Create a new non-blocking IP streaming socket.
sock | The address of the socket to create. |
true
on success. On error, false
is returned bool net_socket_listen | ( | evutil_socket_t | sock, | |
int | backlog | |||
) |
Start listening on the given socket.
sock | The socket to listen on. | |
backlog | The number of connections to backlog. |
true
if we're now listening on the socket. On error, false
is returned. bool net_socket_make_nonblocking | ( | evutil_socket_t | sock | ) |
Make the given socket non-blocking.
sock | The socket to make non-blocking. |
true
if the socket is now non-blocking. On error, false
is returned.