aboutsummaryrefslogtreecommitdiffstats
path: root/include/comms.hpp
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2022-04-25 17:48:52 -0500
committerMatt Strapp <matt@mattstrapp.net>2022-04-25 17:49:31 -0500
commit6889e2d66b710c241b3884fc28610a9e6be4e610 (patch)
tree30aabe5e28a4306c41d7d73a248ed174bd36f0a5 /include/comms.hpp
downloadcsci4211-6889e2d66b710c241b3884fc28610a9e6be4e610.tar
csci4211-6889e2d66b710c241b3884fc28610a9e6be4e610.tar.gz
csci4211-6889e2d66b710c241b3884fc28610a9e6be4e610.tar.bz2
csci4211-6889e2d66b710c241b3884fc28610a9e6be4e610.tar.lz
csci4211-6889e2d66b710c241b3884fc28610a9e6be4e610.tar.xz
csci4211-6889e2d66b710c241b3884fc28610a9e6be4e610.tar.zst
csci4211-6889e2d66b710c241b3884fc28610a9e6be4e610.zip
A
Diffstat (limited to '')
-rw-r--r--include/comms.hpp32
1 files changed, 32 insertions, 0 deletions
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