#ifndef TCP_H #define TCP_H #include #include #ifdef _WIN32 #include typedef SSIZE_T ssize_t; #else #include #endif void tcp_global_initialize_sockets(void); typedef struct TcpServer TcpServer; typedef struct TcpConnection TcpConnection; // returns NULL on errors, and prints the error TcpServer* tcp_server_create(const char* ip, uint16_t port); void tcp_server_destroy(TcpServer* server); // returns NULL on errors, and prints the error TcpConnection* tcp_server_accept(TcpServer* server); void tcp_connection_destroy(TcpConnection* connection); // returns amount transmittet >0 on success, ==0 if client was disconnected, and <0 on error ssize_t tcp_recieve(TcpConnection* connection, uint8_t* data, size_t amount); // returns amount transmittet >0 on success, ==0 if client was disconnected, and <0 on error ssize_t tcp_send(TcpConnection* connection, uint8_t* data, size_t amount); #endif