May 2019
Intermediate to advanced
478 pages
11h 21m
English
We can iterate through an fd_set using a simple for loop. Essentially, we start at 1, since all socket descriptors are positive numbers, and we continue through to the largest known socket descriptor in the set. For each possible socket descriptor, we simply use FD_ISSET() to check if it is in the set. If we wanted to call CLOSESOCKET() for every socket in the fd_set master, we could do it like this:
SOCKET i;for (i = 1; i <= max_socket; ++i) { if (FD_ISSSET(i, &master)) { CLOSESOCKET(i); }}
This may seem like a brute-force approach, and it actually kind of is. However, these are the tools that we have to work with. FD_ISSET() runs very fast, and it's likely that processor time spent on other socket operations ...
Read now
Unlock full access