From: Arseny S. <am...@ic...> - 2002-05-25 00:43:39
|
Hello Sam, Saturday, May 25, 2002, 6:41:49 AM, you wrote: >> This is a nice feature to have, so I would appreciate it if someone >> could tell me how to set connection timeout for a socket. >> Do we have a "dedicated TCP/IP guru" here? Sam> Thanks to Jason and John for their insights! Sam> The fact that there are two very different suggestions is quite scary: Sam> it basically means that there is no standard way to do this. IANATCPIPG, but Jason's approach seems standard - it's already used in socket-wait. MSDN: connect ..... If no error occurs, connect returns zero. Otherwise, it returns SOCKET_ERROR, and a specific error code can be retrieved by calling WSAGetLastError. On a blocking socket, the return value indicates success or failure of the connection attempt. With a nonblocking socket, the connection attempt cannot be completed immediately. In this case, connect will return SOCKET_ERROR, and WSAGetLastError will return WSAEWOULDBLOCK. In this case, there are three possible scenarios: -- Use the select function to determine the completion of the connection request by checking to see if the socket is writeable. -- ... (windows specific) -- ... (windows specific) -- Best regards, Arseny mailto:am...@ic... |