Re: [twsocket] FTP Server - Identify moment of Put file
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
Re: [twsocket] FTP Server - Identify moment of Put file
Synchronous function Put always return false, but file is succesfully transfered to server... I don't know why... Please, help :) I assume you are now referring to the FTP client software. You need to check StatusCode for the FTP server response code, 200 for OK, with the full textual server response in LastResponse. RequestResult is non-zero when the request completes, but may be a non-FTP error such as file not found or DNS failure. The return code of Put (and the other sync methods) is whether RequestResult is non-zero, ie the request started OK, not that it succeeded OK. For the FTP client side, you can use my TMagFTP component, that hides most of this stuff from you, allowing transfer of multiple files and subdirectories with a single function call. http://www.magsys.co.uk/delphi/magxfer.asp 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] FTP Server - Identify moment of Put file
thanks for the explain. After Put, I checked LastResponse property and always has value '150 Opening data connection for Also property Connected is setted to False. If I can not fix it, then I'll use Your pack :) 2011/5/8 Angus Robertson - Magenta Systems Ltd an...@magsys.co.uk: Synchronous function Put always return false, but file is succesfully transfered to server... I don't know why... Please, help :) I assume you are now referring to the FTP client software. You need to check StatusCode for the FTP server response code, 200 for OK, with the full textual server response in LastResponse. Â RequestResult is non-zero when the request completes, but may be a non-FTP error such as file not found or DNS failure. The return code of Put (and the other sync methods) is whether RequestResult is non-zero, ie the request started OK, not that it succeeded OK. For the FTP client side, you can use my TMagFTP component, that hides most of this stuff from you, allowing transfer of multiple files and subdirectories with a single function call. http://www.magsys.co.uk/delphi/magxfer.asp 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
Re: [twsocket] FTP Server - Identify moment of Put file
How to identify moment of uploaded file ? I'd like to do some operations on file, which come from client OnStorSessionClosed triggers when PUT finishes, you need to check AError to see if it worked, then the Client parameter gives you access to the file details, ie Client.FilePath, Client.DataStream, etc. 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] FTP Server - Identify moment of Put file
Many thanks ! It's working. I have one more question: Is possible to send file from server to client without request from client ? 2011/5/6 Angus Robertson - Magenta Systems Ltd an...@magsys.co.uk: How to identify moment of uploaded file ? I'd like to do some operations on file, which come from client OnStorSessionClosed triggers when PUT finishes, you need to check AError to see if it worked, then the Client parameter gives you access to the file details, ie Client.FilePath, Client.DataStream, etc. 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
Re: [twsocket] FTP Server - Identify moment of Put file
*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