Indy FTP server question

Giganews Newsgroups
Subject: Indy FTP server question
Posted by:  Tony Caduto (acadu…@amsoftwaredesign.com)
Date: Fri, 16 Jan 2004

Hi,
I have a Indy FTP server and it works great, except when our Mainframe
connects to it.
It seems the mainframe is doing something weird and it seems the datachannel
thread never fires when they send me a file.

Is it possible for a client to send and not use a datachannel to send the
file?

As far as I can tell all data transfer should be going through here:
(I have added some debugging stuff so I know if the mainframe connections
are going through, and when they send none of the message files get created)
When I send a file from anyother client it works as expected.  This is
driving me nuts....

procedure TIdDataChannelThread.Run;
var
  LStrStream: TMemoryStream; //is faster than StringStream
  instrings,test:tstringlist;
  temp:tmemorystream;
  tempstr:string;
begin
    test:= tstringlist.create;
    test.Add('started datachannel');
    test.SaveToFile('d:\startdatachannel'+intTostr(threadid)+'.txt');
  try
    try
      try
        try
          if Data is TStream then begin
            case FFtpOperation of
              ftpRetr:begin
                          FDataChannel.WriteStream(TStream(Data),False);
                          test.Clear;
                          test.Add('starting retrieve');

test.SaveToFile('d:\startretr'+intTostr(threadid)+'.txt');
                      end;
              ftpStor: begin
                            instrings:=tstringlist.create;
                            temp:= tmemorystream.Create;
                            try
                              FDataChannel.ReadStream(temp, -1, True);
                              temp.Position:=0;
                              instrings.LoadFromStream(temp);
                              instrings.Text:=
adjustlinebreaks(instrings.Text);
                              instrings.SaveToFile('d:\junktest.txt');
                              temp.clear;
                              instrings.SaveToStream(temp);
                              temp.Position:=0;
                              tstream(data).copyfrom(temp,temp.Size);
                            finally
                                freeandnil(temp);
                                freeandnil(instrings);
                            end;

                          // FDataChannel.ReadStream(TStream(Data), -1,
True);

                      end;
            end;
          end else begin

            case FFtpOperation of
              ftpRetr: begin
                            FDataChannel.Writestrings(Data as Tstrings);
                            test.Clear;
                            test.Add('starting retrieve');

test.SaveToFile('d:\startretr'+intTostr(threadid)+'.txt');

                      end;
              ftpStor:
                begin
                    LStrStream := TMemoryStream.Create;
                  try
                    FDataChannel.ReadStream(LStrStream, -1, True);
                    instrings:=tstringlist.create;
                    try
                      instrings.LoadFromStream(lstrstream);
                      instrings.Text:= adjustlinebreaks(instrings.Text);
                      lstrstream.Clear;
                      instrings.SaveToStream(lstrstream);

                    finally
                        freeandnil(instrings);
                    end;

                  // SplitLines(LStrStream.Memory,
LStrStream.Size,TStrings(Data));
                  finally
                    FreeAndNil(LStrStream);
                  end;
                end;//ftpStor
            end;//case
          end;
        finally
          FreeAndNIL(FData);
        end;
      finally
        FDataChannel.Disconnect;
      end;
      FControlChannel.WriteRFCReply(FOKReply); //226
    except
      FControlChannel.WriteRFCReply(FErrorReply); //426
    end;
  finally
        Stop;
  end;
end;

Replies