hat-util  0.6.14
Utility library
socket.h File Reference
#include <stdbool.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include "buff.h"
Include dependency graph for socket.h:

Go to the source code of this file.

Data Structures

struct  hat_socket_t
 

Macros

#define HAT_SOCKET_SUCCESS   0
 
#define HAT_SOCKET_ERROR   1
 
#define HAT_SOCKET_TYPE_IP4_TCP   0
 
#define HAT_SOCKET_TYPE_IP4_UDP   1
 

Typedefs

typedef uint32_t hat_socket_ip4_addr_t
 
typedef uint16_t hat_socket_port_t
 

Functions

int hat_socket_setup ()
 
void hat_socket_cleanup ()
 
int hat_socket_addr_resolve (char *name, hat_socket_ip4_addr_t *host)
 
int hat_socket_addr_convert (char *addr, hat_socket_ip4_addr_t *host)
 
int hat_socket_open (hat_socket_t *s, int type)
 
int hat_socket_close (hat_socket_t *s)
 
int hat_socket_set_blocking (hat_socket_t *s, bool blocking)
 
int hat_socket_connect (hat_socket_t *s, hat_socket_ip4_addr_t host, hat_socket_port_t port)
 
int hat_socket_bind (hat_socket_t *s, hat_socket_ip4_addr_t host, hat_socket_port_t port)
 
int hat_socket_listen (hat_socket_t *s, int backlog)
 
int hat_socket_accept (hat_socket_t *s, hat_socket_t *client)
 
int hat_socket_send (hat_socket_t *s, hat_buff_t *data)
 
int hat_socket_send_to (hat_socket_t *s, hat_buff_t *data, hat_socket_ip4_addr_t host, hat_socket_port_t port)
 
int hat_socket_receive (hat_socket_t *s, hat_buff_t *data)
 
int hat_socket_receive_from (hat_socket_t *s, hat_buff_t *data, hat_socket_ip4_addr_t host, hat_socket_port_t port)
 

Macro Definition Documentation

◆ HAT_SOCKET_ERROR

#define HAT_SOCKET_ERROR   1

◆ HAT_SOCKET_SUCCESS

#define HAT_SOCKET_SUCCESS   0

◆ HAT_SOCKET_TYPE_IP4_TCP

#define HAT_SOCKET_TYPE_IP4_TCP   0

◆ HAT_SOCKET_TYPE_IP4_UDP

#define HAT_SOCKET_TYPE_IP4_UDP   1

Typedef Documentation

◆ hat_socket_ip4_addr_t

typedef uint32_t hat_socket_ip4_addr_t

◆ hat_socket_port_t

typedef uint16_t hat_socket_port_t

Function Documentation

◆ hat_socket_accept()

int hat_socket_accept ( hat_socket_t s,
hat_socket_t client 
)

◆ hat_socket_addr_convert()

int hat_socket_addr_convert ( char *  addr,
hat_socket_ip4_addr_t host 
)

◆ hat_socket_addr_resolve()

int hat_socket_addr_resolve ( char *  name,
hat_socket_ip4_addr_t host 
)

◆ hat_socket_bind()

int hat_socket_bind ( hat_socket_t s,
hat_socket_ip4_addr_t  host,
hat_socket_port_t  port 
)

◆ hat_socket_cleanup()

void hat_socket_cleanup ( )

◆ hat_socket_close()

int hat_socket_close ( hat_socket_t s)

◆ hat_socket_connect()

int hat_socket_connect ( hat_socket_t s,
hat_socket_ip4_addr_t  host,
hat_socket_port_t  port 
)

◆ hat_socket_listen()

int hat_socket_listen ( hat_socket_t s,
int  backlog 
)

◆ hat_socket_open()

int hat_socket_open ( hat_socket_t s,
int  type 
)

◆ hat_socket_receive()

int hat_socket_receive ( hat_socket_t s,
hat_buff_t data 
)

◆ hat_socket_receive_from()

int hat_socket_receive_from ( hat_socket_t s,
hat_buff_t data,
hat_socket_ip4_addr_t  host,
hat_socket_port_t  port 
)

◆ hat_socket_send()

int hat_socket_send ( hat_socket_t s,
hat_buff_t data 
)

◆ hat_socket_send_to()

int hat_socket_send_to ( hat_socket_t s,
hat_buff_t data,
hat_socket_ip4_addr_t  host,
hat_socket_port_t  port 
)

◆ hat_socket_set_blocking()

int hat_socket_set_blocking ( hat_socket_t s,
bool  blocking 
)

◆ hat_socket_setup()

int hat_socket_setup ( )