vessel/core/include/socket.h
Arija A. 0a8709bf31
refact: Rename src->core
Signed-off-by: Arija A. <ari@ari.lt>
2025-06-14 02:27:39 +03:00

68 lines
1.7 KiB
C

#ifndef VESSEL_SOCKET_H_
#define VESSEL_SOCKET_H_
#include "conf.h"
#include "def.h"
#include "file.h"
#include <sys/socket.h>
typedef socklen_t vs_SockLen;
/* TODO: Thread safety? */
typedef enum {
vs_SocketDomain_IPv4 = 0,
vs_SocketDomain_IPv6,
vs_SocketDomain_BT,
vs_SocketDomain_local,
} vs_SocketDomain;
typedef enum {
vs_SocketType_TCP = 0,
vs_SocketType_UDP,
vs_SocketType_packet,
vs_SocketType_raw,
} vs_SocketType;
typedef enum {
_vs_SocketOption_sock_start = 0,
vs_SocketOption_sock_reuseaddr,
vs_SocketOption_sock_broadcast,
vs_SocketOption_sock_keepalive,
vs_SocketOption_sock_linger,
vs_SocketOption_sock_readto,
vs_SocketOption_sock_writeto,
_vs_SocketOption_sock_end,
vs_SocketOption_tcp_nodelay,
vs_SocketOption_tcp_maxseg,
_vs_SocketOption_tcp_end,
vs_SocketOption_ip_ttl,
vs_SocketOption_ip_hdrinc,
_vs_SocketOption_ip_end,
_vs_SocketOption_end,
} vs_SocketOption;
bool vs_Socket_new(vs_File *fsocket, vs_SocketDomain domain, vs_SocketType type);
bool vs_Socket_setopt(vs_File *fsocket,
vs_SocketOption opt,
const void *value,
vs_SockLen value_size);
bool vs_Socket_bind(vs_File *fsocket, const struct sockaddr *addr, vs_SockLen addrlen);
bool vs_Socket_accept(vs_File *fserver,
vs_File *client,
struct sockaddr *addr,
vs_SockLen *addrlen);
bool vs_Socket_listen(vs_File *fsocket, int backlog);
size_t vs_Socket_recv(vs_File *fsocket, void *buf, size_t count);
size_t vs_Socket_send(vs_File *fsocket, const void *buf, size_t count);
#endif /* VESSEL_SOCKET_H_ */