Hi,

i modified TBlockSocket.Connect as follows. Works for me since about 5 
years without any problem (Windows with Delphi and Linux with FPC).
I added FConnectionTimeout as new property for TBlockSocket.

Alex

//-------------------------------------------------------------------------------------------------------------
procedure TBlockSocket.Connect(IP, Port: string);
var
  Sin: TVarSin;
begin
  SetSin(Sin, IP, Port);
  if FLastError = 0 then
  begin
    if FSocket = INVALID_SOCKET then
      InternalCreateSocket(Sin);
    if FConnectionTimeout > 0 then
    begin
      // connect in non-blocking mode
      NonBlockMode := true;
      SockCheck(synsock.Connect(FSocket, Sin));
      if (FLastError = WSAEINPROGRESS) OR (FLastError = WSAEWOULDBLOCK) then
        if not CanWrite(FConnectionTimeout) then
        begin
          FLastError := WSAETIMEDOUT;
          FLastErrorDesc := GetErrorDesc(FLastError);
        end;
      NonBlockMode := false;
    end else begin
      // connect in blocking mode
      SockCheck(synsock.Connect(FSocket, Sin));
      if FLastError = 0 then
        GetSins;
    end;
    FBuffer := '';
    FLastCR := False;
    FLastLF := False;
  end;
  ExceptCheck;
  DoStatus(HR_Connect, IP + ':' + Port);
end;            


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public

Reply via email to