Re: [twsocket] TFtpCli and FTP server in passive mode

2011-05-13 Thread Francois PIETTE

Hello Fabrice,


I can send you login and password to test on a private mail if you want.
This FTP server (Filezilla) work fine with a filezilla client.


I have received it and I was able to test your FTP server.
I can reproduce the error and found what the error is. It was shown in all 
your messages from start but I didn't noticed it ! The answer for PASV 
command is wrong. The answer starts with the code 27 while it should start 
with code 227.

Your server replies:
   27 Entering Passive Mode (213,56,128,2,5,95)
While it should reply:
   227 Entering Passive Mode (213,56,128,2,5,95)

The component expect response code 227 which never comes. It may work with 
other FTP client which do not check the response as ICS does. I checked with 
FileZilla client which also obviously receive the 27 response but it is 
accepted.


This is defenitely not a problem with ICS but from YOUR SERVER. You should 
find out why your server has a bad answer to the PASV command.

Maybe you have edited the the message file of your server ?

--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be


- Original Message - 
From: Fabrice Vendé techni...@infocob.com
To: ICS support mailing twsocket@elists.org; Technique INFOCOB 
techni...@infocob.com

Sent: Thursday, May 12, 2011 6:26 PM
Subject: Re: [twsocket] TFtpCli and FTP server in passive mode


Le 12/05/2011 17:42, Francois PIETTE a écrit :

I have tested your code and it works perfectly from here.
Here is the log using YOUR code and ICS-V7 updated form SVN repository 
right now:


I have downloaded and installed the last update 
(http://wiki.overbyte.be/arch/icsv7w.zip) on my Delphi 2010.

And I have exactly the same problem.
TftpClient.put seems to be ignored.


The differences between your test and mine are:
1) I updated my ICS source code from SVN reporistory (I mean using SVN 
client, not downloading the snapshot). Should not make any difference.

2) I'm using Delphi XE.
3) I made a small application while it looks this is part of a larger 
application.



I have just tested on Delphi XE with exactly the same result !


I'am using ICS (FTP, http and Tsmtp) components since more than 10 years
I have no problem on FTP server which allows Active mode.
This new problem is only in Passive mode.

Since something wrong from the large application could corrupt code 
anywhere, I suggest you build a new trivial application with the code and 
try it alone.


You may also try the demo application FtpTst provided with ICS.

Already tested with same problem.



Since what you want to do is so basic, it is extremely improbable that you 
found a bug in ICS. There must be something special on your computer. 
Maybe a path problem where you use an old ICS version ? Maybe some dcu 
floating around ? Also maybe there is a bug in Delphi 2010. Have you 
installed all updates ?

I have tried on Delphi 2006 and Delphi 2010 in ICS version 6 and ICS
Version 7 and last  daily Build.
On Delphi XE with last Daily build.
My Delphi 2006 and 2010 are not on the same computer. My Delphi 2006 is
on a Windows 7 pro 32 bits.
My Delphi 2010 and Delphi XE are on the same computer (Windows 7 pro 64
bits).



I have tried another way I do this :
procedure TForm8.icsClick(Sender: TObject);
begin
   FtpClient1.HostName:=site.text;
   FtpClient1.username:=login.text;
   FtpClient1.password:=password.text;

   FtpClient1.Passive:=true;
   FRunning:=true;
   FtpClient1.connect;

end;


And use event OnRequestDone :

procedure TForm8.FtpClient1RequestDone(Sender: TObject; RqType: TFtpRequest;
  ErrCode: Word);
begin

 if (ErrCode  0) and  (ErrCode  1) then
 begin
FlastErreur:='Requete effectuée Rq=' + IntToStr(Ord(RqType)) +
' Erreur='+ FtpClient1.ErrorMessage;
AjouterLog(FlastErreur);
 end
 else
 begin
FlastErreur:= 'Requete effectuée Rq=' + IntToStr(Ord(RqType)) +
' Erreur='+ IntToStr(ErrCode);
AjouterLog(FlastErreur);
if ErrCode=0 then FlastErreur:='';
 end;

if not FRunning then
Exit;


case RqType of
ftpConnectAsync: begin
  ftpclient1.User;
  end;
ftpUserAsync:  ftpclient1.pass;
ftpPassAsync:
begin
ftpclient1.HostDirName:='.';
ftpclient1.Cwd;
end;
ftpCwdAsync:begin
  FtpClient1.LocalFileName:='h:\test.txt';
  FtpClient1.HostFileName:='test.txt';
  ftpclient1.put;
 end;
ftpPutAsync: ftpclient1.Quit;
ftpQuitAsync: begin
  AjouterLog('Effectuée !');
  FRunning := FALSE;
  end;
end;

end;


But I have exactly the quasi the same problem, but that is new it that I
get an ErrCode=27 :
Log 

[twsocket] Possible CliId duplication

2011-05-13 Thread Anton S.
In OverbyteIcsWSocketS unit, TCustomWSocketServer.TriggerSessionAvailable 
method, Client.FCliId is determined as incremental counter. But as this counter 
is resetted after $7F, it is possible that some client IDs are duplicated. 
Of course it would be a very rare case but it could lead to serious troubles if 
an application uses CliId fields for some identification.

-- 
Anton
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Possible CliId duplication

2011-05-13 Thread Arno Garrels
Anton S. wrote:
 In OverbyteIcsWSocketS unit,
 TCustomWSocketServer.TriggerSessionAvailable method, Client.FCliId is
 determined as incremental counter. But as this counter is resetted
 after $7F, it is possible that some client IDs are duplicated. Of
 course it would be a very rare case but it could lead to serious
 troubles if an application uses CliId fields for some identification.

It is only guaranteed that _connected clients never share
the same CliId. This field exists mainly because client objects 
cannot be identified reliably by their memory address in 
multi-threaded apps. 

-- 
Arno Garrels

  


 
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Possible CliId duplication

2011-05-13 Thread Anton S.
It is only guaranteed that _connected clients never share the same CliId.
I couldn't see _where_ it is guaranteed... It's quite possible to have 1st 
client with ID 1 connected for a long, long time while others connect and 
disconnect very frequently (i.e. large proxy and a client downloading huge file 
thru it). They could fill the counter and it would reset to ID 1 which already 
exists.

-- 
Anton
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Possible CliId duplication

2011-05-13 Thread Francois PIETTE

It is only guaranteed that _connected clients never share the same CliId.
I couldn't see _where_ it is guaranteed... It's quite possible to have 1st 
client with ID 1 connected for a long, long time while others connect and 
disconnect very frequently (i.e. large proxy and a client downloading huge 
file thru it). They could fill the counter and it would reset to ID 1 
which already exists.


Let's do some computation: the ID wrap around after 2.147.483.647 
connections. If you have 100 connections/disconnections per second, then it 
will take 248 days to wrap around.


So you are right: if a client connect and stay connected for 248 days, and 
during that very long time you continuesly have 100 
connections/disconnections per second, then yes there will be a problem. In 
my opinion, this will never occur.


--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Possible CliId duplication

2011-05-13 Thread Anton S.
Let's do some computation: the ID wrap around after 2.147.483.647 
connections. If you have 100 connections/disconnections per second, then it 
will take 248 days to wrap around.

Well,
  if FClientNum = $7F then
currently it wraps around after 8,388,607 what is very little and might be 
achieved in 23 hours (less than 1 day!).

-- 
Anton
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Possible CliId duplication

2011-05-13 Thread Angus Robertson - Magenta Systems Ltd
   if FClientNum = $7F then
 currently it wraps around after 8,388,607 

That is probably my bug, missed an F.  Will be fixed before you manage to
reproduce 8 million FTP connections in a single session.

Angus


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] TFtpCli and FTP server in passive mode

2011-05-13 Thread Fabrice Vendé

Hello François,

Le 13/05/2011 08:01, Francois PIETTE a écrit :

Hello Fabrice,


I can send you login and password to test on a private mail if you want.
This FTP server (Filezilla) work fine with a filezilla client.


I have received it and I was able to test your FTP server.
I can reproduce the error and found what the error is. It was shown in 
all your messages from start but I didn't noticed it ! The answer for 
PASV command is wrong. The answer starts with the code 27 while it 
should start with code 227.

Your server replies:
 27 Entering Passive Mode (213,56,128,2,5,95)
While it should reply:
 227 Entering Passive Mode (213,56,128,2,5,95)

The component expect response code 227 which never comes. It may work 
with other FTP client which do not check the response as ICS does. I 
checked with FileZilla client which also obviously receive the 27 
response but it is accepted.


This is defenitely not a problem with ICS but from YOUR SERVER. You 
should find out why your server has a bad answer to the PASV command.

Maybe you have edited the the message file of your server ?


I have asked to our System Administrator :
It's seems to be a problem with the Ftp-helper of pfense (open source 
Firewall) which return 27.

We are looking for a solution to avoid this.

Thank you for your help.

Best regards,
-
Fabrice



--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be


- Original Message - From: Fabrice Vendé 
techni...@infocob.com
To: ICS support mailing twsocket@elists.org; Technique INFOCOB 
techni...@infocob.com

Sent: Thursday, May 12, 2011 6:26 PM
Subject: Re: [twsocket] TFtpCli and FTP server in passive mode


Le 12/05/2011 17:42, Francois PIETTE a écrit :

I have tested your code and it works perfectly from here.
Here is the log using YOUR code and ICS-V7 updated form SVN 
repository right now:


I have downloaded and installed the last update 
(http://wiki.overbyte.be/arch/icsv7w.zip) on my Delphi 2010.

And I have exactly the same problem.
TftpClient.put seems to be ignored.


The differences between your test and mine are:
1) I updated my ICS source code from SVN reporistory (I mean using 
SVN client, not downloading the snapshot). Should not make any 
difference.

2) I'm using Delphi XE.
3) I made a small application while it looks this is part of a larger 
application.



I have just tested on Delphi XE with exactly the same result !


I'am using ICS (FTP, http and Tsmtp) components since more than 10 years
I have no problem on FTP server which allows Active mode.
This new problem is only in Passive mode.

Since something wrong from the large application could corrupt code 
anywhere, I suggest you build a new trivial application with the code 
and try it alone.


You may also try the demo application FtpTst provided with ICS.

Already tested with same problem.



Since what you want to do is so basic, it is extremely improbable 
that you found a bug in ICS. There must be something special on your 
computer. Maybe a path problem where you use an old ICS version ? 
Maybe some dcu floating around ? Also maybe there is a bug in Delphi 
2010. Have you installed all updates ?

I have tried on Delphi 2006 and Delphi 2010 in ICS version 6 and ICS
Version 7 and last  daily Build.
On Delphi XE with last Daily build.
My Delphi 2006 and 2010 are not on the same computer. My Delphi 2006 is
on a Windows 7 pro 32 bits.
My Delphi 2010 and Delphi XE are on the same computer (Windows 7 pro 64
bits).



I have tried another way I do this :
procedure TForm8.icsClick(Sender: TObject);
begin
   FtpClient1.HostName:=site.text;
   FtpClient1.username:=login.text;
   FtpClient1.password:=password.text;

   FtpClient1.Passive:=true;
   FRunning:=true;
   FtpClient1.connect;

end;


And use event OnRequestDone :

procedure TForm8.FtpClient1RequestDone(Sender: TObject; RqType: 
TFtpRequest;

  ErrCode: Word);
begin

 if (ErrCode  0) and  (ErrCode  1) then
 begin
FlastErreur:='Requete effectuée Rq=' + IntToStr(Ord(RqType)) +
' Erreur='+ FtpClient1.ErrorMessage;
AjouterLog(FlastErreur);
 end
 else
 begin
FlastErreur:= 'Requete effectuée Rq=' + IntToStr(Ord(RqType)) +
' Erreur='+ IntToStr(ErrCode);
AjouterLog(FlastErreur);
if ErrCode=0 then FlastErreur:='';
 end;

if not FRunning then
Exit;


case RqType of
ftpConnectAsync: begin
  ftpclient1.User;
  end;
ftpUserAsync:  ftpclient1.pass;
ftpPassAsync:
begin
ftpclient1.HostDirName:='.';
ftpclient1.Cwd;
end;
ftpCwdAsync:begin
  FtpClient1.LocalFileName:='h:\test.txt';
  FtpClient1.HostFileName:='test.txt';
  ftpclient1.put;
  

Re: [twsocket] Possible CliId duplication

2011-05-13 Thread Arno Garrels
Angus Robertson - Magenta Systems Ltd wrote:
   if FClientNum = $7F then

@Anton Thanks!

 currently it wraps around after 8,388,607
 
 That is probably my bug, missed an F.  

Actually two ;)
Anton is realy good in finding such slips. 

-- 
Arno Garrels
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Possible CliId duplication

2011-05-13 Thread Francois PIETTE

  if FClientNum = $7F then
currently it wraps around after 8,388,607 


That is probably my bug, missed an F.  


Should probably be MAXINT to avoid any issue with integer size change.

--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be