#ifndef COMM_UTIL_H #define COMM_UTIL_H #include "util.hpp" struct CONN_STAT { int id; // Unique id to identify a client instance bool isLoggedIn; // Used by server to identify that this connection is logged // in struct timeb lastTime; // Last time this connection was used (used to detect // s2c closure) bool recInitHeader; // False until initial header is recieved bool expectingHeader; // The message to be read is a header (irrelevent for // senders) enum LinkType linkType; // MESSAGE_LINK (persistent) or FILE_LINK (one off) enum Direction direction; // C2S or S2C char name[9]; // The user this connection is with int nBuffered; // number of bytes in the buffer int messageLen; // size of the current message being sent (includes header) int nToDo; // num bytes to do before current messsage is completed (message // len --> 0) bool changeDirection; // Flag to change the direction of the connection once // the current communication finishes bool shouldClose; // Flag to destroy this connection }; int Send_NonBlocking(int sockFD, BYTE *data, struct CONN_STAT *pStat, struct pollfd *pPeer); int Recv_NonBlocking(int sockFD, BYTE *data, struct CONN_STAT *pStat, struct pollfd *pPeer); void SetNonBlockIO(int fd); #endif