In my program If the server is not reachable the connect function take too much time. So i try to give time out to connect using select(). Now the problem is that when i try to
Setting time out for connect() function tcp socket programming in C is not working
Correction. Setting the connect timeout is working. What 'isn't working' is the subsequent recvfrom()
, and that's because you left the socket in non-blocking mode and you don't know what to do with the resulting EAGAIN.
So, either handle that, by using select()
to tell you when the socket is ready to read, or else put the socket back into blocking mode after finishing the connect.