See:
Code:
....
fd_set rfds;
struct timeval tv;
struct sockaddr_in client;
int a=sizeof(client);
tv.tv_sec=0;
tv.tv_usec=0;
FD_ZERO(&rfds);
FD_SET(fd,&rfds);
while (select(fd+1,&rfds,0,0,&tv))
{
if ((l=recv_packet(packet,256,(struct sockaddr*)(&client),&a,0,0,&s))==-1)
return;
last_packet_came=get_time();
switch(*packet) {
.....
}
The code I put here, is a part of the main server.c loop of the game 0verkill-0.16. As you can see the author explicitly callled select, before receiving data from client(s). recv_packet is something implimented by recvfrom plus some crc checks (it's a local function). That `while' you can see, is the main loop of the server. It means till when something is sent, do the cycle (clear?). FD_XXX are all macros, for example FD_SET as far as I know, is for adding a socket file descriptor to your fd set. You can find more details on man pages.