May 2019
Intermediate to advanced
478 pages
11h 21m
English
Our get_client() function accepts a SOCKET and searches through the linked list of connected clients to return the relevant client_info for that SOCKET. If no matching client_info is found in the linked list, then a new client_info is allocated and added to the linked list. Therefore, get_client() serves two purposes—it can find an existing client_info, or it can create a new client_info.
get_client() takes a SOCKET as its input and return a client_info structure. The following code is the first part of the get_client() function:
/*web_server.c except*/struct client_info *get_client(SOCKET s) { struct client_info *ci = clients; while(ci) { if (ci->socket == s) break; ci = ci->next; } if (ci) return ci;
In the preceding code, ...
Read now
Unlock full access