#pragma once #include "message.h" #include "client.h" #include #include // The greated file descriptor is needed for polling the sockets. // It needs to be global for the whole process. // TODO: Should probably just move the polling function to connection.c extern int max_fd; struct Connection { int sockfd; socklen_t addrlen; struct sockaddr_in remote_addr; }; struct Connection* connection_new(unsigned int source_port, const char* source_ip, unsigned int dest_port, const char* dest_ip); void req_finalize(struct Client* client, uint8_t cmdset, uint8_t cmdid, size_t length, union Request* req); void req_send(struct Connection* conn, union Request* req, size_t length);