From 6889e2d66b710c241b3884fc28610a9e6be4e610 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Mon, 25 Apr 2022 17:48:52 -0500 Subject: A --- include/comms.hpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 include/comms.hpp (limited to 'include/comms.hpp') diff --git a/include/comms.hpp b/include/comms.hpp new file mode 100644 index 0000000..1b2a942 --- /dev/null +++ b/include/comms.hpp @@ -0,0 +1,32 @@ +#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 -- cgit v1.2.3