-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.h
28 lines (24 loc) · 817 Bytes
/
client.h
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
#pragma once
/******************
The clientdata struct contains data about each new client who has connected to our server
*******************/
#include "util.h"
struct client_data
{
int fd;
struct sockaddr_in clisock;
socklen_t clisock_len;
};
/* Use a linked list to manage all of our connected clients.
After calling select(), we will iterate through the list and test
if a socket has active data. If so, read out that data. */
struct client_node
{
struct client_node *next;
struct client_data data;
};
struct client_node *cli_list;
struct client_node *accept_new_conn(int hostfd);
void add_new_client(struct client_node **cli_list, struct client_node *new_cli_node);
int get_maxfd(struct client_node *cli_list);
int get_read_fdset(fd_set *readfds, int serverfd, struct client_node *cli_list);