forked from flash/temporary-satori-hole
34 lines
982 B
C
34 lines
982 B
C
|
#ifndef H_SATORI_SOCK
|
||
|
#define H_SATORI_SOCK
|
||
|
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <stdint.h>
|
||
|
#include <stdbool.h>
|
||
|
#include <string.h>
|
||
|
#include <unistd.h>
|
||
|
#include <netdb.h>
|
||
|
#include <fcntl.h>
|
||
|
#include <arpa/inet.h>
|
||
|
#include <sys/types.h>
|
||
|
#include <sys/socket.h>
|
||
|
#include <sys/time.h>
|
||
|
#include <netinet/in.h>
|
||
|
|
||
|
typedef struct _sat_sock {
|
||
|
int sock;
|
||
|
} sat_sock, *sat_sock_ptr;
|
||
|
|
||
|
sat_sock_ptr sat_sock_alloc(void);
|
||
|
void sat_sock_free(sat_sock_ptr ctx);
|
||
|
int sat_sock_connect(sat_sock_ptr ctx, int addrFamily, int sockType, char *host, char *port);
|
||
|
int sat_sock_connect_tcp(sat_sock_ptr ctx, char *host, char *port);
|
||
|
void sat_sock_close(sat_sock_ptr ctx);
|
||
|
bool sat_sock_get_blocking(sat_sock_ptr ctx);
|
||
|
void sat_sock_set_blocking(sat_sock_ptr ctx, bool blocking);
|
||
|
int sat_sock_recv(sat_sock_ptr ctx, uint8_t *buffer, size_t size);
|
||
|
int sat_sock_send(sat_sock_ptr ctx, uint8_t *buffer, size_t count);
|
||
|
int sat_sock_select(sat_sock_ptr ctx, int timeout);
|
||
|
|
||
|
#endif // H_SATORI_SOCK
|