Int maxfdp;
Fd_set FDS;
Struct timeval timeout = {1, 0}; // set select to wait 3 seconds and 3 seconds for polling. If it is not blocked, set it to 0.
While (1)
{
Sendto (SKT, sendline, sizeof (vip_hdr) + 100, 0, (Sa *) saddr, sizeof (SA ));
Fd_zero (& FDs); // clear the set for each loop. Otherwise, the descriptor changes cannot be detected.
Fd_set (SKT, & FDs); // Add Descriptor
Maxfdp = SKT + 1; // Add 1 to the maximum value of the descriptor
Switch (select (maxfdp, & FDS, null, null, & timeout) // select usage
{
Case-1:
Exit (-1 );
Break;
Case 0:
Timeout. TV _sec = 1;
Timeout. TV _usec = 0;
Printf ("\ nhave not recieve net_info packet, send request again! ");
Continue;
Break;
Default:
If (fd_isset (SKT, & FDs) // test whether the SKT is readable, that is, whether there is data on the network.
{
// Printf ("\ n ########### this is ICT 1.1 ################## ########");
N = recvfrom (SKT, recvline, maxline, 0, null, & Len );
Printf ("\ n ########### this is after Recv ####% U ############## ########", n );
Break; // exit the while loop if data is read.
}
}
}