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, the application can:
1. Use select to determine the completion of the connection request by checking if the socket is writeable
примерно так:
Код:
var
FDSetW: TFDSet;
FDSetE: TFDSet;
TimeVal: TTimeVal;
...
FD_ZERO(FDSetW);
FD_ZERO(FDSetE);
FD_SET(FSocket, FDSetW);
FD_SET(FSocket, FDSetE);
TimeVal.tv_sec:=0;
TimeVal.tv_usec:=100;
select(0, nil, @FDSetW, @FDSetE, @TimeVal);
if not FD_ISSET(FSocket, FDSetW) then
raise Exception.Create('connect(): timeout');
__________________
Пишу программы за еду.
__________________