Re: [twsocket] [HELP] FTP Server possible bug ?

2005-05-21 Thread Arno Garrels
Guillaume MAISON wrote:

The DataStream is nil at that time, try this:

procedure TGetProcessingThread.Execute;
var
 aBuf : String;
 i : integer;
begin
abuf := 'One ring to rule them all !'#13#10;
Client.DataStream := TMemoryStream.Create;
for i := 0 to 1000 do
Client.DataStream.Write(PChar(aBuf)^, Length(aBuf));
Client.DataStream.Seek(0, 0);
end;

Arno Garrels

 It's just a guess, sounds like your multithreading isn't designed well.
 Can you explain your thread design in your own words?
 Arno Garrels
 
 well, in that case, the demo for the ftp server has a bad multithreading
 design. 
 
 i'm just using the very same design, and the very same classname ;)
 
 for a detail :
 i have an object that has the OnGetProcessing procedure which is linked
 to the 
 FtpServer's OnGetProcessing.
 within this procedure i'm using a Client Class which is *exactly* like
 TMyClient (also declared as FtpServer.ClientClass before the server
 starts). 
 i'm creating the thread object exactly the same way as in the demo.
 
 the same object that holds the OnGetProcessing procedure holds the
 WorkerThreadTerminated procedure 
 linked to the Thread's OnTerminate event.
 This WorkerThreadTerminated procedure has exactly the same code as in the
 demo. 
 
 In fact i've almost changed anything as it fitted exactly my needs.
 I've only written in the Thread's Execute method the code i needed to
 fill the client Datastream... 
 
 i would suggest you to download the sample i've provided here
 http://nauteus.com/FTPSample.zip. 
 The code in this sample is precisely what doesn't seem to work...
 
 to use that FTP Server :
 1. create the EXE file and run it
 2. within the EXE directory, create an empty file named 'images'
 3. open your favorite ftp client
 4. try to download this file.
 
 it should be, on your ftp client side, a text file... but for me (using
 filezilla) it's empty... 
 
 Thanks for your help,
 
 Guillaume MAISON
 -
 Guillaume MAISON - [EMAIL PROTECTED]
 83, Cours Victor Hugo
 47000 AGEN
 Tél : 05 53 87 91 48 - Fax : 05 53 68 73 50
 e-mail : [EMAIL PROTECTED] - Web : http://nauteus.com

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


Re: [twsocket] [HELP] FTP Server possible bug ?

2005-05-21 Thread Guillaume MAISON
 The DataStream is nil at that time, try this:

 procedure TGetProcessingThread.Execute;
 var
  aBuf : String;
  i : integer;
 begin
 abuf := 'One ring to rule them all !'#13#10;
 Client.DataStream := TMemoryStream.Create;
 for i := 0 to 1000 do
 Client.DataStream.Write(PChar(aBuf)^, Length(aBuf));
 Client.DataStream.Seek(0, 0);
 end;

 Arno Garrels

yes i've seen it... and this demo works perfectly as expected.

in my application, i still have that damn RetrDataSent triggered before 
RetrSessionConnected...
and as there's a RetrSessionDisconnected event triggered, my client received 
the requestdone event
with ftpGetAsync as the request type.
that's where my problems come from...

the thing i don't understand is why that damn RetrDataSent are triggered ?!

as far as i can see, through debugging, it's when sending the '105 Opening Data 
connection' that it posts
a message including FD_WRITE. and when my client socket receive this message, 
it triggers ClientRetrDataSent
which triggers itself the SendNextDataChunk, etc...

this is how i see it.. how i've debugged it... but i may be wrong ! but then, 
where the problem comes from
as the sample provided above works perfectly as expected ?! i won't play to 
send messages for fun...

Guillaume MAISON
-
Guillaume MAISON - [EMAIL PROTECTED]
83, Cours Victor Hugo
47000 AGEN
Tél : 05 53 87 91 48 - Fax : 05 53 68 73 50
e-mail : [EMAIL PROTECTED] - Web : http://nauteus.com


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


Re: [twsocket] [HELP] FTP Server possible bug ?

2005-05-21 Thread Arno Garrels
Guillaume MAISON wrote:
 The DataStream is nil at that time, try this:
 
 procedure TGetProcessingThread.Execute;
 var
  aBuf : String;
  i : integer;
 begin
 abuf := 'One ring to rule them all !'#13#10;
 Client.DataStream := TMemoryStream.Create;
 for i := 0 to 1000 do
 Client.DataStream.Write(PChar(aBuf)^, Length(aBuf));
 Client.DataStream.Seek(0, 0);
 end;
 
 Arno Garrels
 
 yes i've seen it... and this demo works perfectly as expected.
 
 in my application, i still have that damn RetrDataSent triggered before
 RetrSessionConnected...

Have you tried to assign the DataStream in FtpServer1GetProcessing?
DelayedSend := TRUE;
MyClient.FWorkerThread.Client.DataStream := TMemoryStream.Create;
MyClient.FWorkerThread.Resume;
Sleep(0);

Arno Garrels

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


Re: [twsocket] [HELP] FTP Server possible bug ?

2005-05-21 Thread Guillaume MAISON
  in my application, i still have that damn RetrDataSent triggered before
  RetrSessionConnected...

 Have you tried to assign the DataStream in FtpServer1GetProcessing?
 DelayedSend := TRUE;
 MyClient.FWorkerThread.Client.DataStream := TMemoryStream.Create;
 MyClient.FWorkerThread.Resume;
 Sleep(0);

alas yes !

i've done it liek this :
MyClient.datastream:=TMemoryStream.Create;

but, i'm not pretty sure it may have to do w/ the RetrDataSent event...

as i can see, it's like if the client data socket receives a WM_ASYNSELECT
with the FD_WRITE and that it still has the OnDataSent event set to 
ClientRetrDataSent.

below is the procedure that sets this event.

procedure TFtpServer.ClientPassiveSessionAvailable(Sender : TObject; AError  : 
Word);
var
HSocket : TSocket;
Client  : TFtpCtrlSocket;
Data: TWSocket;
begin
[...]
end
else if Client.CurCmdType in [ftpcRETR, ftpcLIST, ftpcNLST, ftpcMLSD] then 
begin  { angus V1.41 }
Client.DataSocket.OnSessionConnected  := ClientRetrSessionConnected;
Client.DataSocket.OnSessionClosed := ClientRetrSessionClosed;
Client.DataSocket.OnDataAvailable := nil;
Client.DataSocket.OnDataSent  := ClientRetrDataSent;
[...]
 it seems to be a combination of that settings plus a message above that 
triggers the OnRetrDataSent...

can't see WHY ! i'm not that familiar with ics design to be able to play around 
with such messages...
all i know is that i've been using the same code that the demo, included it 
within a service
(with no visual forms or anything like that), that i'm using some SQL stuff 
(Zeos) to access a MySQL DB...
and that's all... i don't think that Zeos can be involved, because a message is 
always sent to a specific handle,
a known one...

but the riddle is that doing the same application (the sample) doesn't have the 
same effect...

i'm really puzzled

Guillaume MAISON
-
Guillaume MAISON - [EMAIL PROTECTED]
83, Cours Victor Hugo
47000 AGEN
Tél : 05 53 87 91 48 - Fax : 05 53 68 73 50
e-mail : [EMAIL PROTECTED] - Web : http://nauteus.com


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


Re: [twsocket] [HELP] FTP Server possible bug ?

2005-05-21 Thread Arno Garrels
Guillaume MAISON wrote:
 in my application, i still have that damn RetrDataSent triggered before
 RetrSessionConnected...
 
 Have you tried to assign the DataStream in FtpServer1GetProcessing?
 DelayedSend := TRUE;
 MyClient.FWorkerThread.Client.DataStream := TMemoryStream.Create;
 MyClient.FWorkerThread.Resume;
 Sleep(0);
 
 alas yes !
 
 i've done it liek this :
 MyClient.datastream:=TMemoryStream.Create;
 
 but, i'm not pretty sure it may have to do w/ the RetrDataSent event...

May be, but try again to make a small demo application that shows the problem
and I'm sure someone will/can help you.

Arno Garrels

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


Re: [twsocket] [HELP] FTP Server possible bug ?

2005-05-21 Thread Guillaume MAISON
 May be, but try again to make a small demo application that shows the problem
 and I'm sure someone will/can help you.

i've tried to redo a sample even using the SQL stuff...
everything runs fine...

the only thing i haven't tested yet is re writing a sample as a service...

i'll do it on monday...

thanks a lot for your help...

for now, there won't be any thread and... well if several asks at the same time,
there'll be some waiting on some parts...

Guillaume MAISON
-
Guillaume MAISON - [EMAIL PROTECTED]
83, Cours Victor Hugo
47000 AGEN
Tél : 05 53 87 91 48 - Fax : 05 53 68 73 50
e-mail : [EMAIL PROTECTED] - Web : http://nauteus.com


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


Re: [twsocket] [HELP] FTP Server possible bug ?

2005-05-20 Thread Arno Garrels
It's just a guess, sounds like your multithreading isn't designed well.
Can you explain your thread design in your own words? 
Arno Garrels


Guillaume MAISON wrote:
 Le 20 May 2005 à 16:31, Guillaume MAISON a écrit:
 
 Unless there's something obvious, i don't know why the ftpserver opens
 data for connection though i've set DelayedSend:=True in the
 OnGetProcessing event ? 
 After more and more debugging, i've found something :
 when saying delayedSend to true, the data is, effectively, not sent.
 But, the ftpserver keeps going on telling back to the client '150 opening
 data, etc...'. 
 
 the thing is that doing so, it fires the function
 TCustomWSocket.Send(Data : Pointer; Len : Integer) : integer; 
 Which, in turns, post a message :
 if bAllSent then begin
 { We post a message to fire the FD_WRITE message wich in turn
 will } 
 { fire the OnDataSent event. We cannot fire the event ourself
 } 
 { because the event handler will eventually call send again. 
 } 
 { Sending the message prevent recursive call and stack overflow. 
 } 
 { The PostMessage function posts (places) a message in a window's
 } 
 { message queue and then returns without waiting for the 
 } 
 { corresponding window to process the message. The message will
 be } 
 { seen and routed by Delphi a litle later, when we will be out of
 } 
 { the send function. 
 } 
 PostMessage(Handle,
 WM_ASYNCSELECT,
 FHSocket,
 MakeLong(FD_WRITE, 0));
 end;
 
 This message is then received by the procedure
 TCustomWSocket.Do_FD_WRITE(var msg: TMessage); 
 the thing is that, i have at the same time my thread which is kindly
 retrieving data, but has nothing to send yet... 
 this Do_FD_WRITE procedure triggers the procedure
 TFtpServer.ClientRetrDataSent(Sender : TObject; AError : Word); 
 var
 Client : TFtpCtrlSocket;
 Data   : TWSocket;
 begin
 Data   := TWSocket(Sender);
 Client := TFtpCtrlSocket(Data.Owner);
 
 if Client.AbortingTransfer then
 Exit;
 
 try
 { Trigger the user event for the received data }
 ==TriggerRetrDataSent(Client, Data, AError);
 
 here is the problem... When this procedure (TriggerRetrDataSent) is
 executed, it sends back to the client the fact that 
 the file has been sent. But the Client.Datastream is empty, so my client
 application has retrieved a file, but empty. 
 But as i think that i have received a file, i go on my process
 (disconnecting == which means on server side 
 that the client is destroyed and i have exceptions within my thread) and
 analyzing the received (empty) content. 
 
 Is this normal behavior or ?
 
 Guillaume MAISON
 -
 Guillaume MAISON - [EMAIL PROTECTED]
 83, Cours Victor Hugo
 47000 AGEN
 Tél : 05 53 87 91 48 - Fax : 05 53 68 73 50
 e-mail : [EMAIL PROTECTED] - Web : http://nauteus.com

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