blob: 4db1807778bf873c14b17026cacdc256548f9eee (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
// Author Name: Matt Strapp
// Date: 25 April 2022
// x500: strap012
#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 received
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
|