Hi !
I promise that is the last question :)

Synchronous function "Put" always return false, but file is
succesfully transfered to server...
I don't know why... Please, help :)


Server Source

  FFtpServ := TFtpServer.Create(nil);
  FFtpServ.OnStorSessionClosed := OnAfterPut;
  FFtpServ.OnValidatePut := ValidPut;
  FFtpServ.Addr := FAddr;
  FFtpServ.Port := FPortFTP;
  FFtpServ.TimeoutSecsIdle := 0;
  FFtpServ.Start;


procedure TDM.OnAfterPut(Sender: TObject; Client: TFtpCtrlSocket;
  Data: TWSocket; AError: Word);
var
  Script: string;
begin
  if AError = 0 then
  begin
    Script := '_' + Client.FileName;
    F7z.SZFileName := Client.FileName;
    F7z.Extract();
    FScript.ExecuteFile(Script);
    DeleteFile(PChar(Script));
  end;
end;

procedure TDM.ValidPut(Sender: TObject; Client: TFtpCtrlSocket;
  var FilePath: TFtpString; var Allowed: Boolean);
begin
  FilePath := FDir + '\' + ExtractFileName(FilePath);
end;




Client Part

  FFtp := TFtpClient.Create(nil);
  FFtp.MultiThreaded := True;
  FFtp.UserName := 'lab';
  FFtp.PassWord := 'lab';
  FFtp.Binary := True;
  FFtp.Port := DM.FPortFTP;
  FFtp.HostName := DM.FHostServ;
  FFtp.LocalAddr := DM.FHost;
  FFtp.LocalFileName := 'filee'
  FFtp.HostFileName := 'filee'



      if not FFtp.Connected then
        FFtp.Connect;

      if FFtp.Connected then
      begin
        FFtp.TypeSet;
        if FFtp.Put then
        begin

        end;
      end;





2011/5/6 Angus Robertson - Magenta Systems Ltd <an...@magsys.co.uk>:
>> *Subject:* Re: [twsocket] FTP Server - Identify moment of Put file
>> *From:* Tomasz Maciejewski <macie...@gmail.com>
>> *To:* ICS support mailing <twsocket@elists.org>
>> *Date:* Fri, 6 May 2011 12:46:06 +0200
>> Is possible to send file from server to
>> client without request from client ?
>
> Not really, the FTP server only ever responds to commands from clients,
> it has no concept of running commands on it's own.
>
> In theory, if the client keeps a control connection open and sends a
> 'please wait' command, the server could pause for an event and send a
> custom response to the client to allow the client to start a download.
> But this would need custom commands in client and server.
>
> Assuming this is some private application, the easier solution is for the
> client PC to have a small custom server running, even UDP which is very
> easy, and for the main server to use a simple protocol to sends commands
> to the client, which then triggers the FTP download.
> I did this a few years ago to get 500 remote PCs to download new files on
> demand.
>
> 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
>
--
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

Reply via email to