Forum > Linux

Linux-Lazarus-Indy

(1/7) > >>

scasparz:
Not sure if this is the proper place to put this, but I would like to give it a try. Please Mod forgive me if I erred.

Am using Linux Mint 18.3-64 XFCE, Lazarus 1.8.4 with FPC 3.0.4-3. Trying to break into the TCP world using Indy for Lazarus. Have downloaded Indy version 10.2.0.3 and installed it into Lazarus without issues.

Have located a number of trivia Indy examples at https://github.com/tinydew4/indy-project-demos/tree/master/TCPIP%20Delphi%20%26%20Indy10%20Client%20Server%20Demo.

Have started with the simplest one, that is the first 1_Sample simple string exchange. In this the author provides an elementary TCP client sending a string to an elementary TCP server. Understand this was written for the Indy-Delphi-Windows version. Have managed to port the client one to Linux without significant issues. There are some minimal differences, was not hard to modify. Of course remembered to add the indy path to the Lazarus Project unit path.

Had significant issues trying to port the server demo though. To begin with there seems no way to get the tIdTCPServer widget from the palette and drag it on my form, as this can crash my Lazarus.

Did not give up though. Declared an IdTCPServer property on my form, had it created manually at the Form OnCreate event handler, so far so good. Eg.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TStringServerForm.FormCreate(Sender: TObject);begin  IdTCPServer1 := tIdTCPServer.Create(Self);  IdTCPServer1.Name := 'IdTCPServer1';  IdTCPServer1.Active := False;  IdTCPServer1.ListenQueue := 15;  IdTCPServer1.MaxConnections := 0;  IdTCPServer1.ReuseSocket := rsOSDependent;  IdTCPServer1.TerminateWaitTime := 5000;  // there is no nagle property available for Linux   IdTCPServer1.Bindings.Add.IP   := '127.0.0.1';  IdTCPServer1.Bindings.Add.Port := 6000;  IdTCPServer1.OnConnect := IdTCPServer1Connect;  IdTCPServer1.OnDisconnect := IdTCPServer1Disconnect;  IdTCPServer1.OnException := IdTCPServer1Exception;  IdTCPServer1.OnExecute := IdTCPServer1Execute;end;The above runs fine to the end. Yet there does not seem to be a way to activate server with the:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---IdTCPServer1.Active := Truecommand, which raises an exception and terminates the server app.
 
Still did not give up. Transfered the server demo app to a virtual Windows 7 running Delphi XE which comes with Indy 10 installed. In this case the server demo app worked to a point. I mean I could send a string in Latin from the Mint-Lazarus demo-client-app to the Windows-Delphi demo-server-app, but I could not find a way to include international characters to the string. Believe this must be a transliteration issue. AFAIK Linux uses UTF8 while Redmond uses UTF16. Have used:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---LLine := AContext.Connection.IOHandler.ReadLn(TIdTextEncoding.UTF8);to get the string on the server at the IdTCPServer1Execute OnExecute handler, while similarly I used

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---IdTCPClient1.IOHandler.WriteLn(Edit1.Text, enDefault);at the client to send the string. This did not work. Had some better luck using

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---IdTCPClient1.IOHandler.WriteLn(Edit1.Text, enUTF8);at the client side. While Latin text comes OK, still have failed with international (Greek) chars.
In any case, each and every time I disconnect the client, the server fires the OnException event with message ‘Connection closed gracefully’. Is this an exception really?

To summarize:
1. Is there a newer more stable Indy version for Lazarus-Linux and where to get it from? Similarly are there any specific tweaks that should be done during the Indy installation on Lazarus, other than the usual (eg compile the .lpk twice)?
2. Is there any hope to drag the TCPServer widget from the palette onto the Lazarus form without crashing Lazarus?
3. Is there a way to activate my TCPServer instance on Linux-Lazarus without crashing the app?
4. Is there a way to have the correct transliteration with international character sets between a client and a server? In any case this I believe is a secondary issue as I do not plan a Linux to Windows connection but for educational use only.

and perhaps the most important of them all:
5. Do I stand a chance with Linux-Lazarus-Indy or should I have to look elsewhere? Indy is highly reputable and would be glad in case I could overcome my issues. On the other hand Windows and Delphi are not an option other than for fooling around.

Thanks for your time in advance.

s

denver:
In Linux Version of Indy10, you need to confirm the IPVersion ( id_IPV4 or id_IPv6 )

IdTCPServer1.Bindings.Items[ 0 ].IPVersion := Id_IPv4 ;

balazsszekely:

--- Quote ---To summarize:
1. Is there a newer more stable Indy version for Lazarus-Linux and where to get it from? Similarly are there any specific tweaks that should be done during the Indy installation on Lazarus, other than the usual (eg compile the .lpk twice)?
2. Is there any hope to drag the TCPServer widget from the palette onto the Lazarus form without crashing Lazarus?
3. Is there a way to activate my TCPServer instance on Linux-Lazarus without crashing the app?
4. Is there a way to have the correct transliteration with international character sets between a client and a server? In any case this I believe is a secondary issue as I do not plan a Linux to Windows connection but for educational use only.

and perhaps the most important of them all:
5. Do I stand a chance with Linux-Lazarus-Indy or should I have to look elsewhere? Indy is highly reputable and would be glad in case I could overcome my issues. On the other hand Windows and Delphi are not an option other than for fooling around.

--- End quote ---
Just install the latest version. Most of the issues mentioned above are fixed. You can download the latest version from here: https://svn.atozed.com:444/svn/Indy10 (use a svn client). Alternatively you can install indy with OPM(http://wiki.freepascal.org/Online_Package_Manager)

scasparz:
To begin with many thanks for your kind responses.

Have installed a new vbox installation of Linux Mint 18.2, with FPC 3.0.4-3 and Lazarus 1.8.4. Have test it, got no issues.

Then downloaded Indy10 from http://packages.lazarus-ide.org (version 10.6.2.5457) as suggested by GetMem and have it installed again without issues . Newer version seems to work considerably better than the previous. I can now drag the tIdTCPServer component from the palette onto my form without breaking Lazarus.

Also have added the Id_IPv4 clause as suggested by Denver.

But I still fail to Activate IdTCPServer1 exactly as before with run time message 'RunError(232)'.
Not to mention that as I write code, I get the message:


--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Codetools, Errors: 1IdGlobal.pas(1889,105) Error: expected:; but deprecated found. refering to line:GOffsetFromUTC: TDateTime = 0{$IFDEF HAS_DEPRECATED}{$IFDEF USE_SEMICOLON_BEFORE_DEPRECATED};{$ENDIF} deprecated{$ENDIF}; at the message window.

What am I doing wrong?
s

denver:

--- Quote from: scasparz on June 29, 2018, 04:57:37 am ---To begin with many thanks for your kind responses.

But I still fail to Activate IdTCPServer1 exactly as before with run time message 'RunError(232)'.
Not to mention that as I write code, I get the message:


--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Codetools, Errors: 1IdGlobal.pas(1889,105) Error: expected:; but deprecated found. refering to line:GOffsetFromUTC: TDateTime = 0{$IFDEF HAS_DEPRECATED}{$IFDEF USE_SEMICOLON_BEFORE_DEPRECATED};{$ENDIF} deprecated{$ENDIF}; at the message window.

What am I doing wrong?
s

--- End quote ---

For 'RunError(232)'. , you need to add   cthreads, as the first unit  in unit section in the main  .pas or  .lpr  in linux base and only one

Like this  :

uses
  {$DEFINE UseCThreads}
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Interfaces, // this includes the LCL widgetset
  Forms ;

In the IdGlobal.pas, I just modify as follow and it work for me.

  GOffsetFromUTC: TDateTime = 0 ; deprecated ;

Navigation

[0] Message Index

[#] Next page

Go to full version