-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiClient.h
More file actions
37 lines (33 loc) · 917 Bytes
/
Copy pathMultiClient.h
File metadata and controls
37 lines (33 loc) · 917 Bytes
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
36
37
// -----------------------------------------------------
// file MultiClient.h declares client and server classes
// using example from Beej's Guide to Network Programming
// https://beej.us/guide/bgnet/html/#a-simple-stream-server
//
// M. Williamsen, 24 July 2023
// -----------------------------------------------------
// client base class, subclass to add special behavior
class client
{
public:
client(int sock, char *port, struct sockaddr_storage addr);
void serialize(ostream &);
private:
void startClient();
thread clientThread;
int sock; // socket for connecting
char *port;
struct sockaddr_storage addr;
};
// server base class, subclass to add special behavior
class server
{
public:
server(char *arg);
void serialize(ostream &);
private:
int startServer(void);
char *port;
thread serverThread;
list<client *> theList;
int theSock; // socket for listening
};