25 lines
976 B
C
Executable File
25 lines
976 B
C
Executable File
#pragma once
|
|
#include "endpoint.h"
|
|
#include "tlibc/errors.h"
|
|
#include "tlibc/collections/Array.h"
|
|
|
|
typedef enum SocketShutdownType {
|
|
SocketShutdownType_Receive = 0,
|
|
SocketShutdownType_Send = 1,
|
|
SocketShutdownType_Both = 2,
|
|
} SocketShutdownType;
|
|
|
|
typedef i64 Socket;
|
|
|
|
Result(Socket) socket_open_TCP();
|
|
void socket_close(Socket s);
|
|
Result(void) socket_shutdown(Socket s, SocketShutdownType direction);
|
|
Result(void) socket_bind(Socket s, EndpointIPv4 local_end);
|
|
Result(void) socket_listen(Socket s, i32 backlog);
|
|
Result(Socket) socket_accept(Socket s, NULLABLE(EndpointIPv4*) remote_end);
|
|
Result(void) socket_connect(Socket s, EndpointIPv4 remote_end);
|
|
Result(void) socket_send(Socket s, Array(u8) buffer);
|
|
Result(void) socket_sendto(Socket s, Array(u8) buffer, EndpointIPv4 dst);
|
|
Result(i32) socket_recv(Socket s, Array(u8) buffer);
|
|
Result(i32) socket_recvfrom(Socket s, Array(u8) buffer, NULLABLE(EndpointIPv4*) remote_end);
|