This repository has been archived on 2024-05-21. You can view files and clone it, but cannot push or open issues or pull requests.
temporary-satori-hole/include/sock.h
2023-12-27 01:35:22 +01:00

33 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