I am implementing a socket programming project in C. I am using select()
for waiting for data from client. I have two UDP sockets and select()
is always ignoring one of my sockets.
Can anybody briefly describe where should I start looking for it? This is what my server is doing
waitThreshold.tv_sec = 5000;
waitThreshold.tv_usec = 50;
if (sd > sd1)
max_sd = (sd + 1);
else if(sd1 > sd)
max_sd = (sd1 + 1);
FD_ZERO(&read_sds);
FD_SET(sd, &read_sds);
FD_SET(sd1, &read_sds);
ret = select(max_sd, &read_sds, NULL, NULL, &waitThreshold);
if (ret < 0) {
printf("\nSelect thrown an exception\n");
return 0;
} else if (FD_ISSET(sd, &read_sds)) {
// code for socket one
} else if (FD_ISSET(sd1, &read_sds)) {
// code for socket two
}