> > hi everyone,
> >
> > still working on my ftp service server.
>
> [...snip...]
>
> > The exceptions are triggered because the Client used within the thread is 
> > nil.
> > what i don't understand is why, although i set delayedsend to true,
> > the ftp server begins to open the data connection and says the file is sent 
> > ?
> >
> > any clue ?
>
> besides, i've noticed that it happens only when the server (as a service) has 
> some "visual form".
> i've used your "special unit", Wilfried... it works very well except that it 
> seems that when
> you build an visual application, and transform it as a service (with or 
> without wilfried's unit)
> keeping the visual part, there're some weird stuff with messages, message 
> pump, etc...

> The other part of the thing is that if the service is made as a non-visual 
> application (no log window or anything else)
> it seems to work perfectly.
>
> François, i think you got the point (using an http server as a small client 
> application).

Well in fact, after several hours of testing, there's really a problem :
1       [2005/05/20 16:20:33.250] FTP ClientID=1 : Connection de 192.168.0.49
2       [2005/05/20 16:20:33.390] FTP ClientID=1 Answer : 331 Password required 
for 1.
3       [2005/05/20 16:20:33.546] FTP ClientID=1 : Authentification réussie
4       [2005/05/20 16:20:33.671] FTP ClientID=1 Answer : 230 User 1 logged in.
5       [2005/05/20 16:20:33.812] FTP ClientID=1 Answer : 227 Entering Passive 
Mode (192,168,0,49,144,136).
6       [2005/05/20 16:20:33.890] FTP ClientID=1 : BeginOfThread Thread 
Creation File [IMAGES]
7       [2005/05/20 16:20:34.031] FTP ClientID=1 Answer : 150 Opening data 
connection for IMAGES.
8       [2005/05/20 16:20:34.203] FTP ClientID=1 TID-$000005A4 : FTP : InThread 
File to process : IMAGES
9       [2005/05/20 16:20:34.281] FTP ClientID=1 Answer : 226 File sent ok
10      [2005/05/20 16:20:34.437] FTP ClientID=1 Answer : 221 Goodbye.
11      [2005/05/20 16:20:34.546] FTP ClientID=2 : Connection de 192.168.0.49
12      [2005/05/20 16:20:34.640] FTP ClientID=1 : Déconnection de 192.168.0.49
13      [2005/05/20 16:20:34.734] FTP ClientID=2 Answer : 331 Password required 
for 1.
14      [2005/05/20 16:20:34.921] FTP ClientID=2 : Authentification réussie
15      [2005/05/20 16:20:35.015] FTP ClientID=2 Answer : 230 User 1 logged in.
16      [2005/05/20 16:20:35.109] FTP ClientID=2 Answer : 227 Entering Passive 
Mode (192,168,0,49,144,136).
17      [2005/05/20 16:20:35.187] FTP ClientID=2 : BeginOfThread Thread 
Creation File [IMAGES]
18      [2005/05/20 16:20:35.281] FTP ClientID=2 Answer : 150 Opening data 
connection for IMAGES.
19      [2005/05/20 16:20:35.375] FTP ClientID=2 TID-$00000AFC : FTP : InThread 
File to process : IMAGES
20      [2005/05/20 16:20:35.484] FTP ClientID=2 Answer : 226 File sent ok
21      [2005/05/20 16:20:35.609] FTP ClientID=2 Answer : 221 Goodbye.
22      [2005/05/20 16:20:35.750] FTP ClientID=3 : Connection de 192.168.0.49
23      [2005/05/20 16:20:35.906] FTP ClientID=2 : Déconnection de 192.168.0.49

And here's the code i'm using :
ThreadCreation (within OnGetProcessing) :
Begin
        [..]
                        //DisplayMsg is using SQLite to store logs

          Displaymsg('FTP ClientID='+IntToStr(Client.ID)+' : BeginOfThread 
Thread Creation File ['+Client.FileName+']');
          MyServer := Sender as TFtpServer;
          MyClient := Client as TVigiwareClient;
          MyClient.FWorkerThread := TGetProcessingThread.Create(TRUE);
          MyClient.FWorkerThread.Server          := MyServer;
          MyClient.FWorkerThread.Client          := MyClient;
          MyClient.FWorkerThread.Fdisplay        := DisplayMsg;
          MyClient.FWorkerThread.FHandle         := 0;
          MyClient.FWorkerThread.FreeOnTerminate := TRUE;
          MyClient.FWorkerThread.OnTerminate     := WorkerThreadTerminated;
          MyClient.FWorkerThread.Resume;
          DelayedSend := TRUE;
        [..]
End;

TGetProcessingThread.Execute :
// all variables are ThreadSafe
// Even SendMessage is a thread safe function (uses DisplayMsg which uses 
CriticalSections) :
Begin
        [...]
     try
        try
           try
              if Assigned(Client.DataStream) then
                 Client.DataStream.Destroy;
              Client.DataStream := TMemoryStream.Create;
              SQLImage:=TSQLImageList.Create(Nil);
              SendMessage('FTP : InThread File to process : 
'+uppercase(Client.FileName));
           Except
                 on e : exception do
                    raise exception.Create('FileToProc Except : '+e.Message);
           End;
           try
              new(lp);
              lp^.SelectionType:=uImageInfo.istImageIdf;
              lp^.IdRecord:=PFTPSQLProvider(Client.UserData)^.idRecord;
              lp^.ExcludeImage:=True;
              lp^.ImageFrom:=-1;//StrToInt(Client.FileName);
              lp^.ImageTo:=-1; //StrToInt(Client.FileName);
              SQLImage.SetParameters(lp);
           Except
                 on e : exception do
                    raise exception.Create('SQLImage.SetParameters Except : 
'+e.Message);
           End;
           try
              SQLImage.Open;
           Except
                 on e : exception do
                    raise exception.Create('SQLImage.Open Except : '+e.Message);
           End;
           try
              Dispose(lp);
           Except
                 on e : exception do
                    raise exception.Create('Dispose(lp) Except : '+e.Message);
           End;

           try
              if SQLImage.Recordcount>0 then
              Begin
                   try
                      While not (SQLImage.Eof or Terminated) do
                      Begin
                           
lValue:=StrToInt64(SQLImage.Current.FieldByName('cai_idf_image').AsString);
                           Client.DataStream.Write(lValue, SizeOf(int64));
                           SQLImage.Next;
                           Sleep(0);
                      End;
                   Except
                         on e : exception do
                            raise exception.Create('WhileLoop exception : 
'+e.Message);
                   End;
                   try
                      if Terminated then
                      Begin
                           Client.DataStream.Size:=0;
                           ToSendBack:=False;
                      end;
                   Except
                         on e : exception do
                            raise exception.Create('Terminated exception : 
'+e.Message);
                   End;
              end;
           Except
                 on e : exception do
                    raise exception.Create(e.Message);
           End;

           try
              SendMessage('FTP : InThread File ('+Client.FileName+') process 
over!');
              SendMessage('FTP : InThread Rewind Client.datastream !');
              Client.DataStream.Seek(0,0);
              ToSendBack:=True;
           Except
                 on e : exception do
                    raise exception.Create('Seek Except : '+e.Message);
           End;
        except
              on e : exception do
              Begin
                   ToSendBack:=False;
                   SendMessage('FTP : InThread General Exception : '+e.Message);
              End;
        End;
     finally
            if Assigned(SQLImage) then
               FreeAndNil(SQLImage);
              Terminate;
     End;
End;

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 ?

And now, there's now visual part for it !!!!!!!

i'm really lost....

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

Reply via email to