#ifndef LLCOMM_H__ #define LLCOMM_H__ #include struct Ll_comm_config { /// for client: host name or IP to connact to; /// for server: doesn't matter char host[50]; /// port number to bind to (server) or to connect to (client) int port; /// to act as server or as client bool server; }; class Ll_comm { public: /// initialize low-level communication Ll_comm(Ll_comm_config const& cfg); ~Ll_comm(); /// send an unreliable packet of length 'count' void send_pack(void const* buf, int count); /// receive in 'buf' a pachet of length at most 'count' /// returns: the length of the packet, or -1 if no packet arrives /// in 'timeout' miliseconds int recv_pack(void* buf, int count, int timeout); private: int f_sd; struct sockaddr_in f_adr; }; #endif