2
Good,
I am learning how to work with sockets (never worked) and decided to start with winsocks. I am currently using winsock2.h
and in the tutorial I’m following I came to a part that I can’t understand how it works.
The part I doubt is how the Handle of the various customers is made.
//add master socket to fd set
FD_SET(master, &readfds);
//add child sockets to fd set
for ( i = 0 ; i < max_clients ; i++)
{
s = client_socket[i];
if(s > 0)
{
FD_SET( s , &readfds);
}
}
if (FD_ISSET(master , &readfds))
{....}
Why this if statement
is not always true and how it works? The socket master
is always set. At first I thought it was because it was done set
to clients sockets, but none of them is higher than 0.
I recommend using a crossplatform library, such as boost.
– urb