Hi,

TTCPBlockSocket is a child class of TBlockSocket so it will work.
It will also work with a socks proxy. But the connection timeout is
for the connect form your app to the socks proxy, and not for the connect
from the proxy to the target server, of course.

Alex


Max Terentiev schrieb:
Hi Alexander,

Does this code work for TTCPBlockSocket ?

My app must connect via socks proxy.
Can I use your code for connect with proxy ?

---
With best regards, Max Terentiev.
Business Software Products.
AMS Development Team.
supp...@bspdev.com


----- Original Message ----- From: "Alexander Bauer" <a...@familie-bauer.info>
To: "Ararat Synapse" <synalist-public@lists.sourceforge.net>
Sent: Saturday, October 24, 2009 1:03 AM
Subject: Re: [Synalist] Timeout for Connect


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



------------------------------------------------------------------------------
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


------------------------------------------------------------------------------
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