Re: [twsocket] Wiki...
DNS works. Page seems to be loading. However, it's completely empty. That's what I see. Sent from my iPhone > On 25 Oct 2017, at 23:37, Jarek Karciarzwrote: > > For me too. > > Pozdrawiam > > Jarek Karciarz > > > > -- > Od: za...@hmisys.com > Data: 25 października 2017 22:34:10 > Do: twsocket@lists.elists.org > Temat: [twsocket] Wiki... > >> >> Is it just me or has the Wiki (http://wiki.overbyte.eu/wiki/index.php) >> disappeared? >> >> >> -- >> 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 -- 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] New ICS Proxy Components
Hello, I am a total newbie to SSL. I would like to know if following scenario is possible with TIcsProxy. I have a PostgreSQL 9.6.3 database server with SSL enabled. There are certificate files available. I would like to connect to PostgreSQL server using TIcsProxy SSL enabled. I would like my regular database connection components to use that connection as normal. However, communication will be encrypted. Thanks & regards, Ertan Küçükoğlu -Original Message- From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of Angus Robertson - Magenta Systems Ltd Sent: Friday, July 7, 2017 5:52 PM To: twsocket@lists.elists.org Subject: [twsocket] New ICS Proxy Components TIcsProxy is protocol agnostic and may be used to proxy any TCP protocol, the sample includes SMTP, POPO3, NNTP and telnet. It may be used to allow non-SSL applications to access servers that require SSL such as forums.embarcadero.com. TIcsHttpProxy is a full forward and reverse HTTP/HTTPS proxy with header and body parsing and processing host names and URLs to match the source and destination. Could potentially be used as a caching proxy but needs more events. Can be used to monitor HTTP connections. Reverse proxy targets may be selected according to partial paths, or using an event for more complex selection such as load sharing to multiple targets. Or it can be used to add SSL support to non-SSL servers. The HTTP proxy will uncompress received pages and/or compress pages returned by the proxy. These components require USE_SSL to be set, there is no non-SSL version, but SSL is optional for source and targets. The components support multiple sources and targets, with multiple ports and IP addresses. To n extent, data may be intercepted and changed by the proxy, provided the protocols are not broken. SSL server name identification is supported so multiple hosts can share the same server address and port. A forward proxy generally runs on a client or gateway server, and browsers are configured to redirect all traffic to the proxy, which forwards it to the remote target in the URL, typically logging or examining that target and perhaps rejecting it. The browser may specify authentication login and password, which the proxy sends to the onHttpPxyAuth event. For non-SSL traffic, the proxy processes requests and responses which may be checked and manipulated if necessary. But the browser will send SSL traffic using the CONNECT method which opens a direct connection to the remote server and the proxy behaves as a transparent tunnel passing encrypted data back and forward, so requests and responses can not be seen. A reverse proxy generally runs in front of the remote web server, perhaps to provide SSL access to a non-SSL server, for load sharing between multiple servers, or to direct different URLs to different servers. Potentially, the proxy can cache static pages, but this is not implemented yet. Proxy configuration is based on a concept of multiple sources and targets: Source - TSslWSocketServer listening for incoming source connections, part of TIcsProxy, defined as a collection of IcsHosts. Each source can listen on two different IP addresses BindIpAddr and BindIpAddr2 (perhaps IPv4 and IPv6) each with non-SSL BindNonPort and/or SSL BindSslPort. Multiple source clients can connect to each listening socket. Each source needs a unique HostTag alphabetic name, and one or more HostNames that match DNS and SSL certificate names. Each source should define Proto as HTTP or other, and ForwardProxy is true if that behaviour is required otherwise reverse proxy is assumed. If SSL is used, an SSL certificate must also be specified that matches the HostNames, see below. Note IcsHosts is part of TSslWSocketServer and is used for other server components such as the web server. Target - TSslWSocket that connects to a remote target destination, Part of TProxyClient, at least one for each source client (unless ForwardProxy is defined), defined as a collection of ProxyTargets, each with a HostTag alphabetic name that must match a source in the IcsHosts collection, but for HTTP the request path may be examined and there may be multiple ProxyTargets. Each target specifies TarHost, TarPort and TarSsl as the remote target. If the target is SSL, the remote SSL certificate chain may be validated and reported according to the TCertVerMethod setting. The OnSetTarget event is called immediately before each remote target connection is started and may be used for logging or TarHost, TarPort and TarSsl may be changed to alter the target for this connection only. If TarPort is zero, the source port and SSL method are copied for the target. Once source and target are connected, traffic from source is sent to target, and vice versa. The proxy receives data in a temporary TBytes buffer of size RxBuffSize (default 64K). For HTTP, entire request and response headers are saved into a String for ease of processing and each
Re: [twsocket] Firemonkey on OSX
> -Original Message- > From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of Angus Robertson - Magenta Systems Ltd > Sent: Friday, April 7, 2017 10:46 AM > To: twsocket@lists.elists.org > Subject: Re: [twsocket] Firemonkey on OSX > > > It seems that svn is not working or at least on my system but I was > > able to get the latest (436) in ZIP format. > > The DNS was messed up for a few days, but SVN is zipped at 11pm each day and also available for download. > > Angus Hello Angus, Can we get a heads up when SVN is up and running again, please? Just to confirm , SVN address for version 8 is still: http://svn.overbyte.be:8443/svn/ics/trunk Correct? Thanks & regards, Ertan Küçükoğlu -- 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
[twsocket] Right SVN link for most recent code
Hi, I want to be sure that following SVN link is correct for V8 final. As I check Source/Include/OverbyteIcsDefs.inc and read version as 8.09. If it is wrong, I would like to have right SVN link, please. My trials ended with errors. Thanks. -- 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] Problem with TFtpClient - Access Violation error
Hello, Finally source of the problem found. As I suspected, FtpClient doing a Free of the assigned MemoryStream. TCustomFtpCli.DoGetAsync() procedure line no: 5211 { open the destination file } { Don't open a file if we're on FDisplayFileFlag } if not FDisplayFileFlag then try DestroyLocalStream; // <--- HERE THIS LINE FREE THE ASSIGNED MEMORYSTREAM if FResumeAt <= 0 then begin if not Assigned(FLocalStream) and not FStreamFlag then begin FLocalStream := OpenFileStream(FLocalFileName, fmCreate); { V2.105 } if FShareMode <> 0 then begin { Not default mode, need to close and reopen file with } { the given mode } FreeAndNil(FLocalStream); FLocalStream := OpenFileStream(FLocalFileName, fmOpenWrite + FShareMode); end; end; end What I did to solve my problem is to change my code in OnRequestDone() procedure as below: ftpDirAsync: begin if not Assigned(cls.DirStream) then begin AddToLog(cls, '*** ERROR: LocalStream not assigned'); Exit(); end; if cls.DirStream.Size = 0 then begin AddToLog(cls, '*** ERROR: DirStream = 0'); Exit(); end; cls.FtpList := TStringList.Create; try // finally // load FTP file directory, make sure it's not empty SetString(TempString, PAnsiChar(cls.DirStream.Memory), cls.DirStream.Size); cls.FtpList.Text := TempString; cls.FileNameList := TStringList.Create(); try GetFileNamesFromFtpList(cls.FtpList, cls.FileNameList, ' '); cls.DownloadList.Clear(); // AddToLog(cls.Id, 'File download filter: ' + cls.DownloadFileMask); FilterFilesInList(cls.FileNameList, cls.DownloadList, cls.DownloadFileMask); finally cls.FileNameList.Free(); end; finally cls.FtpList.Free(); cls.Ftp.LocalStream := nil; // <--- HERE THIS LINE ADDED AND PROBLEM SOLVED cls.DirStream.Clear(); //cls.DirStream := nil; //cls.FStreamCreated := False; end; cls.Ftp.TypeSetAsync(); end; I didn't see anywhere that TFtpClient.LocalStream is to be assigned a nil right after its usage, but it seems to be the case. Just a feedback for mailing list archieves. Thanks & regards, Ertan Küçükoğlu -Original Message- From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of Ertan Küçükoğlu Sent: Wednesday, September 14, 2016 3:27 PM To: 'ICS support mailing' <twsocket@lists.elists.org> Subject: Re: [twsocket] Problem with TFtpClient - Access Violation error > Yes, but when you read or write a stream, the next read/write position > is where you last left it, and you probably read > beyond the stream end, and then got an AV trying to write there. > > Clear the stream before every request. Something is odd on my side and I cannot find it. This is a single form application. Current code does below. 1- Create a MemoryStream and TFtpClient at the time form created. 2- It is only OnError and OnRequestDone events are assigned to FtpClient component 3- MemoryStream is not touched if there is an error condition with the download (I am not getting any error for the first pass in terms of ftp download sequence anyway) 4- Do a MemoryStream.Clear just before each pass, before even starting a connection (and I get AV right on the line I am doing Clear() for second pass. First pass is fine) 5- Ftp.LocalStream is assigned to MemoryStream for each pass. 6- Do a MemoryStream.Free when form destroy (and I get another AV there if there is one or more pass trials) - There is no MemoryStrem.Free (or Ftp.LocalStream.Free) anywhere in my code other than form destroy. - If it is not created, I would be getting an AV for the first pass. - I see Assigned(MemoryStream) = True if I put a break point in the debugging - I see MemoryStream having value of '()' in the Watch List before calling MemoryStream.Clear() Additionally, I see below code in TFtpClient code. I have no idea when that is triggered. TCustomFtpCli.DestroyLocalStream procedure around line no 2536: if Assigned(FLocalStream) and (FStreamFlag = FALSE) then begin FLocalStream.Free; FLocalStream := nil; end; Is it possible that run-time create of TFtpClient is setting FStreamFlag to False? However, I should see MemoryStream to be nil in the Watch List. My code which is using the MemoryStream is like below. "Cls" is a class of TMyClass that I defined to hold several other variables: ftpDirAsync: begin if not Assigned(cls.DirStream) then begin AddToLog(cls, '*** ERROR: LocalStream not assigned'); Exit(); end; if cls.DirStream.Size = 0 then begin AddTo
Re: [twsocket] Problem with TFtpClient - Access Violation error
> Yes, but when you read or write a stream, the next read/write position is where you last left it, and you probably read > beyond the stream end, and then got an AV trying to write there. > > Clear the stream before every request. Something is odd on my side and I cannot find it. This is a single form application. Current code does below. 1- Create a MemoryStream and TFtpClient at the time form created. 2- It is only OnError and OnRequestDone events are assigned to FtpClient component 3- MemoryStream is not touched if there is an error condition with the download (I am not getting any error for the first pass in terms of ftp download sequence anyway) 4- Do a MemoryStream.Clear just before each pass, before even starting a connection (and I get AV right on the line I am doing Clear() for second pass. First pass is fine) 5- Ftp.LocalStream is assigned to MemoryStream for each pass. 6- Do a MemoryStream.Free when form destroy (and I get another AV there if there is one or more pass trials) - There is no MemoryStrem.Free (or Ftp.LocalStream.Free) anywhere in my code other than form destroy. - If it is not created, I would be getting an AV for the first pass. - I see Assigned(MemoryStream) = True if I put a break point in the debugging - I see MemoryStream having value of '()' in the Watch List before calling MemoryStream.Clear() Additionally, I see below code in TFtpClient code. I have no idea when that is triggered. TCustomFtpCli.DestroyLocalStream procedure around line no 2536: if Assigned(FLocalStream) and (FStreamFlag = FALSE) then begin FLocalStream.Free; FLocalStream := nil; end; Is it possible that run-time create of TFtpClient is setting FStreamFlag to False? However, I should see MemoryStream to be nil in the Watch List. My code which is using the MemoryStream is like below. "Cls" is a class of TMyClass that I defined to hold several other variables: ftpDirAsync: begin if not Assigned(cls.DirStream) then begin AddToLog(cls, '*** ERROR: LocalStream not assigned'); Exit(); end; if cls.DirStream.Size = 0 then begin AddToLog(cls, '*** ERROR: DirStream = 0'); Exit(); end; cls.DirStream.Seek (0, soFromBeginning); cls.FtpList := TStringList.Create; try // finally // load FTP file directory, make sure it's not empty cls.FtpList.LoadFromStream(cls.DirStream); cls.FileNameList := TStringList.Create(); try GetFileNamesFromFtpList(cls.FtpList, cls.FileNameList, ' '); cls.DownloadList.Clear(); FilterFilesInList(cls.FileNameList, cls.DownloadList, cls.DownloadFileMask); finally cls.FileNameList.Free(); end; finally cls.FtpList.Free(); end; Just cannot see where the problem is. Thanks for all your help. -- 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] Problem with TFtpClient - Access Violation error
-Original Message- From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of Angus Robertson - Magenta Systems Ltd Sent: Wednesday, September 14, 2016 10:33 AM To: twsocket@lists.elists.org Subject: Re: [twsocket] Problem with TFtpClient - Access Violation error > > I have no problem at first pass. File is downloaded just fine. > > Second pass, > > and I get that error. Error is raised after I call "Ftp.DirAsync()". > > You are probably not freeing the stream after reading it during the first pass, and trying to use it a second time without clearing and resetting it. Or freeing the stream and not recreating it. > > Angus It is created for sure. I create the stream once when application started and it is Freed at application close. It maybe that I am not clearing and resetting. Will try that and post result Thanks. -- 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
[twsocket] Problem with TFtpClient - Access Violation error
Hi, Using Delphi 10.1 Starter Edition. ICS 8, subversion revision 1284 (latest as far as I can tell). I am trying to use TFtpClient in Async mode. Application creates TFtpClient at run-time. It is used to download file(s) at given intervals non-stop (7/24). I do not assign any option, or change any parameter value when I create TFtpClient at run-time. I simply couldn't solve my problem of Access Violation error. It maybe my code causing such an error. Though, I wanted to get a second opinion. I have no problem at first pass. File is downloaded just fine. Second pass, and I get that error. Error is raised after I call "Ftp.DirAsync()". I have following lines before I call Directory listing: ftpCwdAsync: begin Ftp.HostFileName := EmptyStr; Ftp.LocalFileName := EmptyStr; if not Assigned(DirStream) then DirStream := TMemoryStream.Create(); Ftp.LocalStream := DirStream; Ftp.DirAsync(); end; Some digging in code and I ended up below lines. OverbyteIcsFtpCli.pas Line: 2603 procedure TCustomFtpCli.LocalStreamWrite(const Buffer; Count : Integer); begin FLocalStream.WriteBuffer(Buffer, Count); end; I am creating DirStream in OnCreate procedure of the form. Above line which create it in case it is not already is added later when I could not solve AV errors. I simply could not understand what is the problem here. Any help is appreciated. Regards, Ertan Küçükoğlu -- 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
[twsocket] FTPClient1 - OnError() event
Hi, I will try to ask my question in an understandable way. If it is not clear, just give it to my lack of sockets knowledge. I might be choosing confusing words. I would like to know that my command finished successfully. That I do in OnRequestDone() event. However, there are times that there will be errors (ftp server down, file not present, connection dropped for some reason, etc.) When such a thing occurs, I get error message displayed using OnError() event. If logic reaches to OnError() event of TFtpClient does it mean that OnRequestDone() won't be called until another command run on the component (such as change directory, connect, disconnect, etc)? Can I put a "Operation interrupted" kind of message after I print error message on the screen? If an OnError() event is not absolute stop of execution, how can I know it will continue? Thanks. Regards, Ertan Küçükoğlu -- 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
[twsocket] FW: TFtpClient - listing filenames using stream
Hello, I confirm that I am still not able to solve my issue below. Thanks. -Original Message- From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of Ertan Küçükoğlu Sent: Thursday, July 21, 2016 7:53 PM To: twsocket@lists.elists.org Subject: [twsocket] TFtpClient - listing filenames using stream Hi, I am not quite sure as to what version of ICS I have. I read V8.23 somewhere in “svn-changelog-icsv8.txt” file, and TFtpClient.FtpClientID is “ICS FTP Client V8.09”. In one of my projects I did use TIdFTP for downloading some files. Project is finished, and running now. Recently, it’s blocking operation type of working started to be a poblem. I am checking TFtpClient samples as to how can I do the switch for non-blocking ftp downloads. So far I believe, I can use TFtpClient to download a file which I know it’s name and full URL. Though; 1- I do need some help to list files in the FTP server I am connecting. I want to use LocalStream (Please see below) 2- It’s maybe me, but I couldn’t find any sample as to listing of files in a directory using wildcards and excluding directories (or some how identifying them). Currently, I do not know if I can or how to pass this wildcard to the file listing in order to get only the relevant files listed. My current code is: procedure TForm10.FtpClient1RequestDone(Sender: TObject; RqType: TFtpRequest; ErrCode: Word); var TempString: string; begin Memo1.Lines.Add(FormatDateTime('-mm-dd hh:nn:ss.zzz', now) + ' On request:' + IntToStr(Ord(RqType))); if ErrCode <> 0 then begin Memo1.Lines.Add(FormatDateTime('-mm-dd hh:nn:ss.zzz', now) + ' *** ERROR: ' + FtpClient1.ErrorMessage); if RqType <> ftpOpenAsync then FtpClient1.QuitAsync; Exit(); end; case RqType of ftpOpenAsync:FtpClient1.UserAsync(); ftpUserAsync:FtpClient1.PassAsync(); ftpPassAsync:FtpClient1.CwdAsync(); ftpCwdAsync: begin FtpClient1.HostFileName := EmptyStr; FtpClient1.LocalFileName := EmptyStr; FtpClient1.LocalStream := TMemoryStream.Create(); FtpClient1.LsAsync(); end; ftpLsAsync: begin // FtpClient1.LocalStream.Position := 0; // Using only these 3 lines also giving me similar result // SetLength(TempString, FtpClient1.LocalStream.Size); // CopyMemory(Pointer(TempString), TMemoryStream(FtpClient1.LocalStream).Memory, FtpClient1.LocalStream.Size); SetString(TempString, PChar(TMemoryStream(FtpClient1.LocalStream).Memory), FtpClient1.LocalStream.Size div SizeOf(Char)); Memo1.Lines.Add('-'); Memo1.Lines.Add(TempString); Memo1.Lines.Add('-'); FtpClient1.TypeSetAsync(); end; ftpTypeSetAsync: begin FtpClient1.HostFileName := 'abcdef.txt'; FtpClient1.LocalFileName := edtLocalPath.Text + '\' + FtpClient1.HostFileName; FtpClient1.GetAsync; end; ftpGetAsync: begin FStatus := FtpClient1.StatusCode = 226; FtpClient1.QuitAsync; end; ftpQuitAsync:if FStatus then Memo1.Lines.Add('File Download OK'); else Memo1.Lines.Add('Unknown RqType: ' + IntToStr(Ord(RqType))); end; end; Part of what I get in Memo is something like below: = Beginning = 2016-06-22 04:12:01.784 On request:4 2016-06-22 04:12:01.787 > PASV 2016-06-22 04:12:01.938 < 227 Entering Passive Mode (5,229,203,64,227,54). 2016-06-22 04:12:01.953 > NLST 2016-06-22 04:12:02.188 < 150 Opening data connection for (N/A) (*hidden*). 2016-06-22 04:12:02.338 < 226 Closing data connection. File: N/A 2016-06-22 04:12:02.340 ! 167bytes received/sent in 297 milliseconds 2016-06-22 04:12:02.342 On request:8 - മ⸊മ匊偍〰䈮义〲㔱〱䵓ぐ〰⸱千ൖ㈊ㄵറ㈊ㄵല㈊㠰വ㈊〶റ㈊〶ല㈊㠰ശ匊ㅋ⹁千ൖ㈊〶ള㈊〶ഴ匊偍〰㈰䈮义䵓ぐ〰⸲千ൖ匊㉋⹁千ൖ㈊〶വ㈊〶ശ - 2016-06-22 04:12:02.361 > TYPE I 2016-06-22 04:12:02.455 < 200 Command okay. ===== END = Thanks. Regards, Ertan Küçükoğlu -- 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
[twsocket] TFtpClient - listing filenames using stream
Hi, I am not quite sure as to what version of ICS I have. I read V8.23 somewhere in “svn-changelog-icsv8.txt” file, and TFtpClient.FtpClientID is “ICS FTP Client V8.09”. In one of my projects I did use TIdFTP for downloading some files. Project is finished, and running now. Recently, it’s blocking operation type of working started to be a poblem. I am checking TFtpClient samples as to how can I do the switch for non-blocking ftp downloads. So far I believe, I can use TFtpClient to download a file which I know it’s name and full URL. Though; 1- I do need some help to list files in the FTP server I am connecting. I want to use LocalStream (Please see below) 2- It’s maybe me, but I couldn’t find any sample as to listing of files in a directory using wildcards and excluding directories (or some how identifying them). Currently, I do not know if I can or how to pass this wildcard to the file listing in order to get only the relevant files listed. My current code is: procedure TForm10.FtpClient1RequestDone(Sender: TObject; RqType: TFtpRequest; ErrCode: Word); var TempString: string; begin Memo1.Lines.Add(FormatDateTime('-mm-dd hh:nn:ss.zzz', now) + ' On request:' + IntToStr(Ord(RqType))); if ErrCode <> 0 then begin Memo1.Lines.Add(FormatDateTime('-mm-dd hh:nn:ss.zzz', now) + ' *** ERROR: ' + FtpClient1.ErrorMessage); if RqType <> ftpOpenAsync then FtpClient1.QuitAsync; Exit(); end; case RqType of ftpOpenAsync:FtpClient1.UserAsync(); ftpUserAsync:FtpClient1.PassAsync(); ftpPassAsync:FtpClient1.CwdAsync(); ftpCwdAsync: begin FtpClient1.HostFileName := EmptyStr; FtpClient1.LocalFileName := EmptyStr; FtpClient1.LocalStream := TMemoryStream.Create(); FtpClient1.LsAsync(); end; ftpLsAsync: begin // FtpClient1.LocalStream.Position := 0; // Using only these 3 lines also giving me similar result // SetLength(TempString, FtpClient1.LocalStream.Size); // CopyMemory(Pointer(TempString), TMemoryStream(FtpClient1.LocalStream).Memory, FtpClient1.LocalStream.Size); SetString(TempString, PChar(TMemoryStream(FtpClient1.LocalStream).Memory), FtpClient1.LocalStream.Size div SizeOf(Char)); Memo1.Lines.Add('-'); Memo1.Lines.Add(TempString); Memo1.Lines.Add('-'); FtpClient1.TypeSetAsync(); end; ftpTypeSetAsync: begin FtpClient1.HostFileName := 'abcdef.txt'; FtpClient1.LocalFileName := edtLocalPath.Text + '\' + FtpClient1.HostFileName; FtpClient1.GetAsync; end; ftpGetAsync: begin FStatus := FtpClient1.StatusCode = 226; FtpClient1.QuitAsync; end; ftpQuitAsync:if FStatus then Memo1.Lines.Add('File Download OK'); else Memo1.Lines.Add('Unknown RqType: ' + IntToStr(Ord(RqType))); end; end; Part of what I get in Memo is something like below: = Beginning = 2016-06-22 04:12:01.784 On request:4 2016-06-22 04:12:01.787 > PASV 2016-06-22 04:12:01.938 < 227 Entering Passive Mode (5,229,203,64,227,54). 2016-06-22 04:12:01.953 > NLST 2016-06-22 04:12:02.188 < 150 Opening data connection for (N/A) (*hidden*). 2016-06-22 04:12:02.338 < 226 Closing data connection. File: N/A 2016-06-22 04:12:02.340 ! 167bytes received/sent in 297 milliseconds 2016-06-22 04:12:02.342 On request:8 - മ⸊മ匊偍〰䈮义〲㔱〱䵓ぐ〰⸱千ൖ㈊ㄵറ㈊ㄵല㈊㠰വ㈊〶റ㈊〶ല㈊㠰ശ匊ㅋ⹁千ൖ㈊〶ള㈊〶ഴ匊偍〰㈰䈮义䵓ぐ〰⸲千ൖ匊㉋⹁千ൖ㈊〶വ㈊〶ശ - 2016-06-22 04:12:02.361 > TYPE I 2016-06-22 04:12:02.455 < 200 Command okay. = END ===== Thanks. Regards, Ertan Küçükoğlu -- 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
[twsocket] TFtpClient - listing filenames
Hi, I am not quite sure as to what version of ICS I have. I read V8.23 somewhere in “svn-changelog-icsv8.txt” file, and TFtpClient.FtpClientID is “ICS FTP Client V8.09”. In one of my projects I did use TIdFTP for downloading some files. Project is finished, and running now. Recently, it’s blocking operation type of working started to be a problem. I am checking TFtpClient samples as to how can I do the switch for non-blocking ftp downloads. So far I believe, I can use TFtpClient to download a file which I know its name and full URL. Though; 1- I do need some help to list files in the FTP server I am connecting. I want to use LocalStream (Please see below) 2- It’s maybe me, but I couldn’t find any sample as to listing of files in a directory using wildcards and excluding directories (or somehow identifying them). Currently, I do not know if I can or how to pass this wildcard to the file listing in order to get only the relevant files listed. My current code is: procedure TForm10.FtpClient1RequestDone(Sender: TObject; RqType: TFtpRequest; ErrCode: Word); var TempString: string; begin Memo1.Lines.Add(FormatDateTime('-mm-dd hh:nn:ss.zzz', now) + ' On request:' + IntToStr(Ord(RqType))); if ErrCode <> 0 then begin Memo1.Lines.Add(FormatDateTime('-mm-dd hh:nn:ss.zzz', now) + ' *** ERROR: ' + FtpClient1.ErrorMessage); if RqType <> ftpOpenAsync then FtpClient1.QuitAsync; Exit(); end; case RqType of ftpOpenAsync:FtpClient1.UserAsync(); ftpUserAsync:FtpClient1.PassAsync(); ftpPassAsync:FtpClient1.CwdAsync(); ftpCwdAsync: begin FtpClient1.HostFileName := EmptyStr; FtpClient1.LocalFileName := EmptyStr; FtpClient1.LocalStream := TMemoryStream.Create(); FtpClient1.LsAsync(); end; ftpLsAsync: begin // FtpClient1.LocalStream.Position := 0; // Using only these 3 lines also giving me similar result // SetLength(TempString, FtpClient1.LocalStream.Size); // CopyMemory(Pointer(TempString), TMemoryStream(FtpClient1.LocalStream).Memory, FtpClient1.LocalStream.Size); SetString(TempString, PChar(TMemoryStream(FtpClient1.LocalStream).Memory), FtpClient1.LocalStream.Size div SizeOf(Char)); Memo1.Lines.Add('-'); Memo1.Lines.Add(TempString); Memo1.Lines.Add('-'); FtpClient1.TypeSetAsync(); end; ftpTypeSetAsync: begin FtpClient1.HostFileName := 'abcdef.txt'; FtpClient1.LocalFileName := edtLocalPath.Text + '\' + FtpClient1.HostFileName; FtpClient1.GetAsync; end; ftpGetAsync: begin FStatus := FtpClient1.StatusCode = 226; FtpClient1.QuitAsync; end; ftpQuitAsync:if FStatus then Memo1.Lines.Add('File Download OK'); else Memo1.Lines.Add('Unknown RqType: ' + IntToStr(Ord(RqType))); end; end; Part of what I get in Memo is something like below: = Beginning = 2016-06-22 04:12:01.784 On request:4 2016-06-22 04:12:01.787 > PASV 2016-06-22 04:12:01.938 < 227 Entering Passive Mode (5,229,203,64,227,54). 2016-06-22 04:12:01.953 > NLST 2016-06-22 04:12:02.188 < 150 Opening data connection for (N/A) (*hidden*). 2016-06-22 04:12:02.338 < 226 Closing data connection. File: N/A 2016-06-22 04:12:02.340 ! 167bytes received/sent in 297 milliseconds 2016-06-22 04:12:02.342 On request:8 - മ⸊മ匊偍〰䈮义〲㔱〱䵓ぐ〰⸱千ൖ㈊ㄵറ㈊ㄵല㈊㠰വ㈊〶റ㈊〶ല㈊㠰ശ匊ㅋ⹁千ൖ㈊〶ള㈊〶ഴ匊偍〰㈰䈮义䵓ぐ〰⸲千ൖ匊㉋⹁千ൖ㈊〶വ㈊〶ശ - 2016-06-22 04:12:02.361 > TYPE I 2016-06-22 04:12:02.455 < 200 Command okay. = END ===== Thanks. Regards, Ertan Küçükoğlu -- 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
[twsocket] TFtpClient - listing filenames in stream
Hi, I am not quite sure as to what version of ICS I have. I read V8.23 somewhere in “svn-changelog-icsv8.txt” file, and TFtpClient.FtpClientID is “ICS FTP Client V8.09”. In one of my projects I did use TIdFTP for downloading some files. Project is finished, and running now. Recently, it’s blocking operation type of working started to be a poblem. I am checking TFtpClient samples as to how can I do the switch for non-blocking ftp downloads. So far I believe, I can use TFtpClient to download a file which I know it’s name and full URL. Though; 1- I do need some help to list files in the FTP server I am connecting. I want to use LocalStream (Please see below) 2- It’s maybe me, but I couldn’t find any sample as to listing of files in a directory using wildcards and excluding directories (or some how identifying them). Currently, I do not know if I can or how to pass this wildcard to the file listing in order to get only the relevant files listed. My current code is: procedure TForm10.FtpClient1RequestDone(Sender: TObject; RqType: TFtpRequest; ErrCode: Word); var TempString: string; begin Memo1.Lines.Add(FormatDateTime('-mm-dd hh:nn:ss.zzz', now) + ' On request:' + IntToStr(Ord(RqType))); if ErrCode <> 0 then begin Memo1.Lines.Add(FormatDateTime('-mm-dd hh:nn:ss.zzz', now) + ' *** ERROR: ' + FtpClient1.ErrorMessage); if RqType <> ftpOpenAsync then FtpClient1.QuitAsync; Exit(); end; case RqType of ftpOpenAsync:FtpClient1.UserAsync(); ftpUserAsync:FtpClient1.PassAsync(); ftpPassAsync:FtpClient1.CwdAsync(); ftpCwdAsync: begin FtpClient1.HostFileName := EmptyStr; FtpClient1.LocalFileName := EmptyStr; FtpClient1.LocalStream := TMemoryStream.Create(); FtpClient1.LsAsync(); end; ftpLsAsync: begin // FtpClient1.LocalStream.Position := 0; // Using only these 3 lines also giving me similar result // SetLength(TempString, FtpClient1.LocalStream.Size); // CopyMemory(Pointer(TempString), TMemoryStream(FtpClient1.LocalStream).Memory, FtpClient1.LocalStream.Size); SetString(TempString, PChar(TMemoryStream(FtpClient1.LocalStream).Memory), FtpClient1.LocalStream.Size div SizeOf(Char)); Memo1.Lines.Add('-'); Memo1.Lines.Add(TempString); Memo1.Lines.Add('-'); FtpClient1.TypeSetAsync(); end; ftpTypeSetAsync: begin FtpClient1.HostFileName := 'abcdef.txt'; FtpClient1.LocalFileName := edtLocalPath.Text + '\' + FtpClient1.HostFileName; FtpClient1.GetAsync; end; ftpGetAsync: begin FStatus := FtpClient1.StatusCode = 226; FtpClient1.QuitAsync; end; ftpQuitAsync:if FStatus then Memo1.Lines.Add('File Download OK'); else Memo1.Lines.Add('Unknown RqType: ' + IntToStr(Ord(RqType))); end; end; Part of what I get in Memo is something like below: = Beginning = 2016-06-22 04:12:01.784 On request:4 2016-06-22 04:12:01.787 > PASV 2016-06-22 04:12:01.938 < 227 Entering Passive Mode (5,229,203,64,227,54). 2016-06-22 04:12:01.953 > NLST 2016-06-22 04:12:02.188 < 150 Opening data connection for (N/A) (*hidden*). 2016-06-22 04:12:02.338 < 226 Closing data connection. File: N/A 2016-06-22 04:12:02.340 ! 167bytes received/sent in 297 milliseconds 2016-06-22 04:12:02.342 On request:8 - മ⸊മ匊偍〰䈮义〲㔱〱䵓ぐ〰⸱千ൖ㈊ㄵറ㈊ㄵല㈊㠰വ㈊〶റ㈊〶ല㈊㠰ശ匊ㅋ⹁千ൖ㈊〶ള㈊〶ഴ匊偍〰㈰䈮义䵓ぐ〰⸲千ൖ匊㉋⹁千ൖ㈊〶വ㈊〶ശ - 2016-06-22 04:12:02.361 > TYPE I 2016-06-22 04:12:02.455 < 200 Command okay. = END ===== Thanks. Regards, Ertan Küçükoğlu -- 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] Pinging multipe hosts
I have prepared two test projects. There is one TMagIpLog component dropped on form for each project. One test project is listening its local TCP port 5000. LogProtocol is set to logprotTcpServer. Second test project is trying to establish a connection to the first test Project using same port number. Below is my code from second test Project. procedure TForm9.Button1Click(Sender: TObject); begin MagIpLog1.LogProtocol := logprotTcpClient; MagIpLog1.RemoteHost := '192.168.1.24'; MagIpLog1.RemoteIpPort := '5000'; MagIpLog1.StartLogging; if Label2.Caption = 'OK' then begin Label3.Caption := 'Connection OK!'; MagIpLog1.StopLogging; end; end; procedure TForm9.MagIpLog1LogChangeEvent(Sender: TObject; Socnr: Integer; LogState: TLogState); begin if LogState = logstateStart then Label1.Caption := 'Start'; if LogState = logstateOK then Label2.Caption:= 'OK'; end; I am seeing that Label3.Caption is not changing at all. It displays 'Label3' always. On the other hand, I read 'Start' and 'OK' texts on relevant components. So, MagIpLog is connecting to other test project. However, connection is, I think, sync. Is there a way to make It async? As you indicated earlier, async connection will solve my problem, in my real code. Thanks. -Original Message- From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of Angus Robertson - Magenta Systems Ltd Sent: Monday, March 14, 2016 12:32 PM To: twsocket@lists.elists.org Subject: Re: [twsocket] Pinging multipe hosts > // PING OK. DO DIRECT TCP CONNECTION > if not TestClientConnection(ClientIP, Err) then begin > Result := '***ERROR: Client TCP connection fail.'; If you really want to do these tests from the server, this needs to become async. You create an array of TWSocket or TMagIpLog components, either one for each client you are going to test or a pool (which is more complicated) setting the Tag to ClientUUID, then you put all your success or fail code in the OnSessionConnected and OnSessionClosed events. Using an array of TMagIpLogs in client mode is easiest, since it already contains threaded ping to test the connection before an open attempt is made, you need a single event onLogChangeEvent and to test LogState. 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] Pinging multipe hosts
Yes, I know that I have to use ICS in sync mode and depend on events. Even I, like many others am not used to think & code like that though, am trying to manage. Actually, I believe I got it. Thing is I don't know how to implement it in my current function. Below is my code where I need to complete my pre-tests. I will appreciate, If you can advise as to how to manage what I am trying to do. Or, you may tell me it is not possible as an answer and I stop losing rest of my remaining hair. Use another way to do it. function TDeneme.GetLicense(ClientTime:TDateTime; ClientIP,ClientUUID,LicenseType:string):string; stdcall; var Err:string; begin if MinutesBetween(now, ClientTime) > 10 then begin Result := '***ERROR: ClientTime'; WriteLicenseLog('GetLicense', ClientIP, ClientUUID, LicenseType, Result); Result := StringToTableToXML(Result); Exit; end; if ClientIP = EmptyStr then begin Result := '***ERROR: ClientIP empty'; WriteLicenseLog('GetLicense', ClientIP, ClientUUID, LicenseType, Result); Result := StringToTableToXML(Result); Exit; end; if ClientUUID = EmptyStr then begin Result := '***ERROR: ClientUUID empty'; WriteLicenseLog('GetLicense', ClientIP, ClientUUID, LicenseType, Result); Result := StringToTableToXML(Result); Exit; end; if LicenseType = EmptyStr then begin Result := '***ERROR: LicenseType empty'; WriteLicenseLog('GetLicense', ClientIP, ClientUUID, LicenseType, Result); Result := StringToTableToXML(Result); Exit; end; // Is Client alive? First PING it. if not PingClient(ClientIP, 500, Err) then begin Result := '***ERROR: Ping fail. ClientIP:' + ClientIP + '.'; if Err <> EmptyStr then Result := Result + ' ' + Err; WriteLicenseLog('GetLicense', ClientIP, ClientUUID, LicenseType, Result); Result := StringToTableToXML(Result); Exit; end; // PING OK. DO DIRECT TCP CONNECTION if not TestClientConnection(ClientIP, Err) then begin Result := '***ERROR: Client TCP connection fail.'; if Err <> EmptyStr then Result := Result + ' ' + Err; WriteLicenseLog('GetLicense', ClientIP, ClientUUID, LicenseType, Result); Result := StringToTableToXML(Result); end; // Code will continue from here once above is solved. Result := 'LICENSE WILL BE GRANTED; WriteLicenseLog('GetLicense', ClientIP, ClientUUID, LicenseType, Result); Result := StringToTableToXML(Result); end; -Original Message- From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of Angus Robertson - Magenta Systems Ltd Sent: Sunday, March 13, 2016 7:35 PM To: twsocket@lists.elists.org Subject: Re: [twsocket] Pinging multipe hosts > Pretty confused and stuck at the moment. Give this to my literally > *no knowledge* of using sockets. Below is as far as it gets. > WSocket.Connect; > Sleep(3500); // Assuming that amount of time is enough for a local tcp > connection. which is I'm afraid a perfect example of why you would be better starting off with my TMagIpLog component, even if you only look at the source code and modify it for your purposes, although certainly the client side will do everthing you need. The component is not designed as a high traffic server, I mostly use for one-one connections between applications. The most important thing is ICS is generally used in async mode, you NEVER have wait loops or sleep, there is an event that fires when a connection successeds or fails, and that is what riggers you next step. The exception is multi-threaded applications that do nothing else until the next ICS call. 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] Pinging multipe hosts
Actually, I started to implement TWSocket in my code before I got your e-mail, Angus. Pretty confused and stuck at the moment. Give this to my literally *no knowledge* of using sockets. Below is as far as it gets. I copy-paste from sample applications. Changed some code as to my understanding. In my scenario, "server connects to client". I don't get to see 'HEY!' message in my client application (check below code), but my server application claims connection is just fine. Server side code: WSocket is a private variable. Server is a webservice VCL application when I am debugging, but will be a windows service application when finished. function TDeneme.TestClientConnection(IP:string):Boolean; begin WSocket := TWSocket.Create(nil); try WSocket.OnSessionConnected := SocketSessionConnected; WSocket.Proto := 'tcp'; WSocket.SocketFamily := sfIPv4; WSocket.Addr := IP; WSocket.LocalAddr := '0.0.0.0'; WSocket.Port := DM.WSOCKET_CLI_PORT; WSocket.LocalPort := DM.WSOCKET_SRV_PORT; WSocket.LineMode := True; WSocket.LineEnd:= #13#10; { Connect is asynchronous (non-blocking). When the session is } { connected (or fails to), we have an OnSessionConnected event } { This is where actual sending of data is done.} WSocket.Tag := -1; WSocket.Connect; Sleep(3500); // Assuming that amount of time is enough for a local tcp connection. Result := WSocket.Tag = 0; WSocket.Close; finally WSocket.Free; end; end; procedure TDeneme.SocketSessionConnected(Sender: TObject; ErrCode: Word); var Buf:string; begin WSocket.Tag := ErrCode; if ErrCode = 0 then begin Buf := 'HEY!' + #13#10; try WSocket.SendStr(Buf); except end; end; end; -- Client side code: Client application is a vcl windows application. procedure TForm4.FormCreate(Sender: TObject); begin // Wait for a TCP connection with WSocket1 do begin Proto := 'tcp'; SocketFamily := sfIPv4; Addr := '0.0.0.0'; Port := '0'; LocalAddr := '0.0.0.0'; LocalPort := DM.WSOCKET_CLI_PORT; LineMode := True; LineEnd:= #13#10; Listen; end; end; procedure TForm4.WSocket1DataAvailable(Sender: TObject; ErrCode: Word); var Buffer : array [0..1023] of AnsiChar; Len: Integer; Src: TSockAddrIn6; SrcLen : Integer; begin if FSenderAddr.sin6_family = AF_INET then begin SrcLen := SizeOf(TSockAddrIn); Len:= WSocket1.ReceiveFrom(@Buffer, SizeOf(Buffer), PSockAddr(@Src)^, SrcLen); if Len >= 0 then begin if (PSockAddr(@FSenderAddr).sin_addr.S_addr = INADDR_ANY) or (PSockAddr(@FSenderAddr).sin_addr.S_addr = PSockAddr(@Src).Sin_addr.S_addr) then begin Buffer[Len] := #0; Label1.Caption := String(Buffer); end; end; end; end; procedure TForm4.WSocket1SessionClosed(Sender: TObject; ErrCode: Word); begin Label1.Caption := 'Connection closed.'; end; procedure TForm4.WSocket1SessionConnected(Sender: TObject; ErrCode: Word); begin Label1.Caption := 'Connected. Listening.'; end; -Original Message- From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of Angus Robertson - Magenta Systems Ltd Sent: Sunday, March 13, 2016 11:04 AM To: twsocket@lists.elists.org Subject: Re: [twsocket] Pinging multipe hosts > I will be writing both server and client softwares. No need for a web > server. In which case the server should only ever listen for TCP connections from clients, which open the connection and send a hello packet once a minute to prove they are alive, expecting a response so they know the server is alive. Your can start with my TMagIpLog component, which can be configured as the client or server, and handles all the opening, retrying and closing of connections, allowing lines of text (ie your protocol) to be send back and forward. http://www.magsys.co.uk/delphi/magics.asp You only need to add a couple of events in your code and it should all be working in an hour. For my old bus project, we had three 'activity servers' that the client PCs contacted in rotation in case of hardware or other problems, and we had a fall back of a UDP listener on the client that listened to UDP broadcasts from the server to force all the clients to immediately call home, and a few others things. Our protocol document was about 50 pages with 40 different commands or something, quite complicated, things like retrieving CCTV from the buses. 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
Re: [twsocket] Pinging multipe hosts
I thought, at first, that ping might be a solution. After reading your post, I better find another way to check if client is running. More details about subject: - I will be writing both applications that running on server and client. - Client will inform server first time it is running thru a webservice. - Client will inform server every minute it is running thru a webservice. - If it is more than a minute and client still didn't inform that it is running, I would like to know that client is really alive, or busy and couldn't say that it is running. - If client is really closed, I will do some database operations on server side. I avoid to use a webservice on client, too. Need something faster and simple, if possible. That won't be much of a CPU and network resource user. Maybe a port listenning on client side for a connection. If a connection occurs from server side, it means it is alive, and connection will be closed. Or, client will say it is alive and connection will be closed? Thanks. --Ertan -Original Message- From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of François Piette Sent: Saturday, March 12, 2016 6:37 PM To: 'ICS support mailing'Subject: Re: [twsocket] Pinging multipe hosts > I have a Windows service application. That needs to check if several > hosts (IP numbers, > no need to DNS resolve) are still alive. Assuming easiest way to ping them. Since that will > require no installation on my clients at all. Please suggest other > ways that you think apply. Ping messages (ICMP) are frequently blocked for servers. If you have control over the hosts, you can be sure to enable it. But ping doesn't mean the services are running, it only means that the server OS is running. The best way to check for an alive host is to try a connection to the host, connection to the application that you must verify. -- francois.pie...@overbyte.be The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) 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 -- 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