Have downloaded Indy version 10.2.0.3 and installed it into Lazarus without issues.
Why such an OLD version? The CURRENT version is 10.6.2(.5462).
IdTCPServer1.Bindings.Add.IP := '127.0.0.1';
IdTCPServer1.Bindings.Add.Port := 6000;
Typical newbie mistake, usually due to bad 3rd party examples. You are adding *2* bindings to the collection, one for 127.0.0.1:0, and the other for 0.0.0.0:6000. You want to add only *1* binding, for 127.0.0.1:6000:
Binding := IdTCPServer1.Bindings.Add;
Binding.IP := '127.0.0.1';
Binding.Port := 6000;
Or:
with IdTCPServer1.Bindings.Add do
begin
IP := '127.0.0.1';
Port := 6000;
end;
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.
Indy's default text encoding is actually US-ASCII, unless you explicitly specify otherwise, either by:
- setting the global GIdDefaultTextEncoding variable in the IdGlobal unit.
- setting the TIdIOHandler.DefStringEncoding property (and TIdIOHandler.DefAnsiEncoding property in pre-Unicode compilers).
- specifying an encoding parameter on a per-read/write operation basis.
Have used:
LLine := AContext.Connection.IOHandler.ReadLn(TIdTextEncoding.UTF8);
to get the string on the server at the IdTCPServer1Execute OnExecute handler, while similarly I used
IdTCPClient1.IOHandler.WriteLn(Edit1.Text, enDefault);
at the client to send the string. This did not work.
Because you are mixing encodings, since enDefault is US-ASCII by default. If you replace enDefault with enUTF8, it should then work OK. Or, you can configure enDefault to be UTF-8 by setting the IdGlobal.GIdDefaultTextEncoding variable to encUTF8.
Had some better luck using
IdTCPClient1.IOHandler.WriteLn(Edit1.Text, enUTF8);
at the client side.
Yes, exactly.
While Latin text comes OK, still have failed with international (Greek) chars.
UTF-8 works fine for the entirety of Unicode, Greek and all.
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?
Yes, that is normal behavior. Indy uses exceptions for error handling and notifications. In a TIdTCPServer, when a client disconnects, subsequent read/write operations on that connection will raise an exception, which you should let TIdTCPServer catch and handle for you so that it can close the socket and clean up the worker thread that was managing that socket.
1. Is there a newer more stable Indy version for Lazarus-Linux and where to get it from?
Yes. Links are on Indy's website:
http://www.indyproject.org/Sockets/Docs/Indy10Installation.aspxhttp://www.indyproject.org/Sockets/Download/DevSnapshot.aspxIndy is also available in Lazarus's "Online Package Manager" (OPM).
2. Is there any hope to drag the TCPServer widget from the palette onto the Lazarus form without crashing Lazarus?
This is the first that I'm hearing that it crashes like that. Do you have any information about the actual crash?
3. Is there a way to activate my TCPServer instance on Linux-Lazarus without crashing the app?
Fix the way you are initializing the server's Bindings.
4. Is there a way to have the correct transliteration with international character sets between a client and a server?
Make sure you are using the same text encoding on both sides.
5. Do I stand a chance with Linux-Lazarus-Indy or should I have to look elsewhere?
Plenty of FPC users are using Indy in Linux. And more users to come in the future as the latest Delphi (and upcoming C++Builder) now supports Linux development, too.
In Linux Version of Indy10, you need to confirm the IPVersion ( id_IPV4 or id_IPv6 )
IdTCPServer1.Bindings.Items[ 0 ].IPVersion := Id_IPv4 ;
Id_IPv4 is the default, unless specified otherwise, either explicitly with the IPVersion property, or implicitly by recompiling Indy with {$DEFINE IdIPv6} enabled in IdCompilerDefines.inc.
You can download the latest version from here: https://svn.atozed.com:444/svn/Indy10 (use a svn client).
Or the nightly ZIPPED version of the latest SVN revision at
https://indy.fulgan.com/ZIP/.
But I still fail to Activate IdTCPServer1 exactly as before with run time message 'RunError(232)'.
Did you fix your incorrect Bindings setup, as described above?
Not to mention that as I write code, I get the message:
Codetools, Errors: 1
IdGlobal.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.
Refer to past discussions on this forum about that issue. The USE_SEMICOLON_BEFORE_DEPRECATED conditional was
supposed to address that very issue. Are you saying it is broken AGAIN? USE_SEMICOLON_BEFORE_DEPRECATED was specifically added for FPC, which handles that line (and 1 other line, in IdWship6.pas) differently than Delphi does.
In the IdGlobal.pas, I just modify as follow and it work for me.
GOffsetFromUTC: TDateTime = 0 ; deprecated ;
Per past discussions, USE_SEMICOLON_BEFORE_DEPRECATED is defined only for FPC 2.4.4 - 2.6.1, as the issue of the semicolon was
supposedly fixed in 2.6.2 to allow the same syntax as Delphi (see below) (especially since Indy puts FPC into Delphi mode). IdCompilerDefines.inc has this code:
{$IFDEF FPC}
...
{$IFDEF FPC_2_4_4_OR_ABOVE}
...
{$IFNDEF FPC_2_6_2_OR_ABOVE}
{$DEFINE USE_SEMICOLON_BEFORE_DEPRECATED} // TODO: which earlier versions require a semicolon?
{$ENDIF}
{$ENDIF}
...
{$ENDIF}
Had never used the deprecated directive before. Tried to experiment a bit, used Lazarus to open a new trivia project where I declared a variable using identical syntax:
var
Form1: TForm1;
pap: Integer; deprecated;
and Lazarus raised exactly the same error again. Tried this on Delphi XE and once more got exactly the same error with the same message.
Delphi, and modern FPC, do not require the extra semicolon:
var
pap: Integer deprecated;
That is why the semicolon is IFDEF'ed for earlier versions of FPC.
Could not find some additional documentation either on the Delphi XE help subsystem or on the internet over deprecated.
http://docwiki.embarcadero.com/RADStudio/en/Declarations_and_Statements_(Delphi)#Hinting_DirectivesAm left with the impression -please correct me if wrong- that this directive only works with procedures or methods but not with variables.
Hinting directives, like deprecated, work with variables, too. The only thing they don't work with is properties (sadly, since Indy has a quite few of those).
Many thanks for your kind help. Without you and GetMem, I simply couldn't have done it.
I'm late to this discussion, but keep in mind that I am Indy's primary developer, so if you have any issues with Indy, you can pass them along to me. Also note that Indy has an issue tracker on GitHub:
https://github.com/IndySockets/Indy/issues.