In a non blocking socket connect, select() always returns 1
I have this code segment that is designed to connect to a server using a socket connection. However if it can not connect to the server within a certain amount of time I would like it to stop trying. I tried to do this with this nonblocking socket and the select command but select is always returning 1 indicating that the server exists when nothing exists at the address I give it. Any Ideas? SOCKET tcp_client( char *hname, char *sname ) { fd_set fdset; struct sockaddr_in peer; SOCKET s; FD_ZERO(&fdset); // FD_SET(STDIN, &fdset); FD_SET(s, &fdset); errno=1; struct timeval tv; tv.tv_sec = 15;