[fpc-pascal] fphttclient, no way to specify a connect timeout

Luca Olivetti luca at ventoso.org
Fri Feb 23 19:24:56 CET 2018


El 23/02/18 a les 18:51, Dimitrios Chr. Ioannidis via fpc-pascal ha escrit:

> 
>    copy the ssockets.pp from <fpc sources>\packages\fcl-net\src dir to 
> your project dir and add the following line
> 
> SetIOTimeout(FIOTimeout);
> 
> to Procedure TInetSocket.Connect; like this


fphttpclient already does that before calling connect and it doesn't work.

As Michael said, the socket must be put in non-blocking mode during the 
connection. This is how synapse does it (but I see that ssockets has no 
provision for toggling between blocking/non-blocking mode):

     if FConnectionTimeout > 0 then
     begin
       // connect in non-blocking mode
       b := NonBlockMode;
       NonBlockMode := true;
       SockCheck(synsock.Connect(FSocket, Sin));
       if (FLastError = WSAEINPROGRESS) OR (FLastError = WSAEWOULDBLOCK) 
then
         if not CanWrite(FConnectionTimeout) then
           FLastError := WSAETIMEDOUT;
       NonBlockMode := b;
     end
     else
       SockCheck(synsock.Connect(FSocket, Sin));


Bye
-- 
Luca




More information about the fpc-pascal mailing list