I created two sockets udp_S, tcp_S (one each for UDP AND TCP).Now I want to wait on select() call until there is any data sent from any UDP client or there is any request for coonection by a TCP client. Here is a brief snippet of my code:
int udp_S,tcp_S;
/*Create sockets using socket()*/
/*Bind address to them using bind()*/
fd_set fd;
FD_ZERO(&fd);
FD__SET(udp_S,&fd);
FD__SET(tcp_S,&fd);
int maxfd=max(udp_S,tcp_S)+1;
retval=select(maxfd,&fd,NULL,NULL,NULL);
if(FD__ISSET(udp_S,&fd)){ /* use recvfrom() to receive data from udp client*/}
if(FD__ISSET(tcp_S,&fd)){/* first using accept() to estblish connection and then using standard recv() send() calls*/}
The problem is that without any request made by any clients my select() call is returning 1 and FD__ISSET(tcp_S,&fd) is also returning 1 after which accept() gives accept error.