LNet

This is an old revision of LNet, edited by Arent at . The current revision is 14133.

lNet or Lightweight Networking Library is a collection of classes and components to enable event-driven TCP or UDP networking. lNet is released under a modified LGPL license (permits static linking).

Template:Web and Networking Programming

Overview

Homepage of the lNet base libraries is: http://lnet.wordpress.com

Contains:
The package consists of base lNet units library, lTelnet for telnet protocol, lFTP for ftp protocol and lNetComponents libraries for providing visual and non-visual components for networking. As of 0.4.0 lHTTP and lSMTP components have been added. Since 0.5.1 there's a MIME support as part of the library mainly for creation of multipart messages for SMTP. Since 0.6.0 lNet supports SSL in a modular way, and SMTP protocol has been extended to full support of SSL/TLS (including runtime STARTTLS negotiation). HTTPS client side is supported too.

Tested on:
The non-visual console components were tested on Win32, Win64, Linux_x86_32, Linux_x86_64, Linux_PPC, Linux_PPC_64, Linux_ARM* (2.1.4+) and FreeBSD_x86_32. The visual (Lazarus packages) components were tested in Win32, Win64, ARM/WinCE, Linux_x86_32, Linux_x86_64 and FreeBSD_x86_32. (gtk1 and gtk2 on unix platforms)

Short history:
As of version 0.3 the package is only single-threaded. I've dropped multithreaded version and now use exclusively LCL features to work.

As of version 0.4 the package has "eventers" which enable per-OS optimalizations and additional flexibility including watching for events on files additionaly to the sockets.

Version 0.5 changed some high level higher protocol API (ftp, http etc.)

Since 0.5.1 WinCE is considered an unstable but supported platform.

Version 0.6 is highly compatible to previous releases.

Authors

Ales Katona (User: Almindor)
Micha Nelissen

License

Modified LGPL (read LICENSE and LICENSE.ADDON included in package).

Contact

You can contact me directly by email or go to #lnet channel on freenode.

News

13th of March 2011:

A new version of lNet was just released. 0.6.5 completes SSL and IPv6 support including server-side and per-socket (for SSL) setting. SSL and IPv6 bugs were fixed as well as some remaining disconnect problems related to server bind errors and lingering sockets. DecodeURL bug introduced in 0.6.4 was also fixed.

9th of May 2010:

A new version of lNet was just released. 0.6.4 adds Qt4 support inside Lazarus (lazarus latest trunk needed, 0.9.30 should be 1st stable with it). There were also numerous fixes (http URL parsing, FTP problems) and one major bug fixed (WinCE compilation with FPC 2.4.0+). Grab it at SVN, packages will be uploaded ASAP.

13th of February 2010:

Well there’s a skip in dates. Anyways version 0.6.3 of lNet has been released, you can find it in the downloads section. There’s been various bugfixes and file renames to avoid FPC conflicts. I didn’t find the time to do the QT4 port as I wanted but it’s in the works now. Some SSL fixes were made as well.

30th of May 2008:

Where to begin? This is a HUGE critical bugfix release. There was about 5 big bugs fixed in SSL section, one logical oversight in Session support. OpenSSL unit was added so WinCE compiles again and SMTP and FTP got bugs fixed in regards to possible desynchronization. I'd urge everyone who uses 0.6.x to update ASAP, but some bugs are also from 0.5.x (specifically the SMTP and FTP event deadlock problem).

For more information on the various bugs, please see the lNet blog.

18th of May 2008:

It seems that due to an oversight in what's packaged with FPC and for which platform, lNet 0.6.x doesn't currently compile on WinCE due to missing OpenSSL unit. The unit is in fpc 2.2.0, but is not compiled for that platform yet (it is in 2.2.1+). I will add the unit to lNet and release 0.6.2 shortly, but until then, WinCE users can work around this by copying this file into their lnetdir/lib directory. (same will be done in 0.6.2 so don't worry)

26th of April 2008:

0.6.1 has been released today. This release fixes an ugly SSL logical bug in regards to the mandatory requirements of Certificate Authority List file and Keyfile proprties of SSLSession. They are no longer needed for normal SSL to work. A minor change in HTTP and handling of SSLSession are also present.

Bugfix release.

20th of April 2008:

0.6.0 has been released! Adding full client-side SSL support (via OpenSSL library) in a modular way. SMTP and HTTP (client) protocols have been already modified to support new features.

23th of March 2008:

0.6.0 is getting closer now, SSL/HTTPS is working (client side) already. Added a new class diagram to the documentation section.

15th of November 2007:

Released 0.5.8a as minor bugfix release. Bugs:

Bugfix release.

16th of September 2007:

Released 0.5.8 as bugfix release. Bugs:

Bugfix release.

20th of August 2007:

Released 0.5.7 as bugfix release. Bugs:

Bugfix release.

04th of August 2007:

Released 0.5.6 as bugfix release. Bugs:

Bugfix release.

15th of July 2007:

Released 0.5.5 as bugfix release. Bugs:

8th of July 2007:

Released 0.5.4 as bugfix release. Bugs:

25th of June 2007:

Released 0.5.3 as bugfix release. Bugs:

11th of June 2007:

Released 0.5.2 as bugfix release. Fixed a windows and winCE bug in LCLEventer which could cause memory corruption in special cases.

1st of June 2007:

Released 0.5.1 according to schedule. New stuff:

This release has been mainly concentrated on the MIME support, the other issues are bug fixes and/or maintenance.

14th of April 2007:

Released 0.5.0 not according to schedule. New stuff:

This is mostly a bugfix and stabilization release. Many planned features got dropped until we got something we felt right with. Sorry for the delay as well but school was keeping me quite occupied lately.

Download

Change Log

Status

* FTP and Telnet still need some additional features like authentication methods.

Roadmap

Items that are struck through have been completed in the indicated version:

* PING requires raw sockets which are only accessible to root on unix/linux platforms. It was decided that lNet won't support this, users who need PING should use the ping and ping6 programs via TProcess.

Dependencies / System Requirements

LNet 0.6+

LNet 0.5

LNet 0.4

Installation

LNet 0.5+:

users who don't want to depend on LCL but use LNet in Lazarus (non-visually), can just compile lnetbase.lpk, which adds all the base units to path.

LNet 0.4:

older lNet is extraced to "lnetpackage" dir. Since 0.4.0 the "visual" and "non visual" packages are in one distribution file.

Ubuntu special notice

Some "missing files" are, in fact, in the "/net" subfolder and are not found by the fpc compiler. Simply copy missing files from the subfolder (lnet.pas, tomwinsock.pas, lfunc.inc...) "/usr/lib/lazarus/components/lnetpackage/lnet" in the "/usr/lib/lazarus/components/lnetpackage" folder (adjust paths as necessary). Then complete the setup by following the installation procedure.

by Steph12358

Documentation

Documentation of lNet is partially done. You can also use Jesus' diagrams of classes and units as basic reference.

Documentation of eventer and TCP/UDP protocols: http://members.chello.sk/ales/docs

Overview diagrams can be found here: http://members.chello.sk/ales/docs/diagrams/overview.html
Pictures:
New class diagram
All classes
lNet units
lNet units 2

Docs Mirror and Ongoing Notes: http://z505.com/cgi-bin/powtils/docs/1.6/idx.cgi?file=lnetlufdoc

Usage

TCP/UDP

Drop a TLTCPComponent or TLUDPComponent on a form. Assign OnAccept, OnError, OnReceive, OnConnect and OnDisconnect event handlers. Note that this is optional but in most cases required for functionality.

Client connection is initialized with the Connect call. Arguments are IP address/hostname and port respectivly. Non-blocking connect is used, this means that you DON'T know that you're connected until OnConnect event is fired.

Server connection is initialized with the Listen* call. Argument is port.

address is a string representation of IP eg: '127.0.0.1' or a hostname like 'localhost'.

Sending data to the other side is accomplished with the Send/SendMessage method.

Events of TLNetComponent class.

API changes

0.1 to 0.2 There have been some API changes from 0.1 to 0.2. These were required and should improve the usability of packages. I know API changes are always a PITA but I'll try to keep them minimal from now on. Version 0.3 will be the first beta from which API will remain unchanged (only adding new stuff will be possible).

0.2 to 0.3

0.3 to 0.4 Lots of additions. Only "breakage" is that TLSocket.Port got changed into TLSocket.LocalPort and TLSocket.PeerPort for consistency reasons.

0.4 to 0.5 We did some API cleanup which resulted in API breakage.

0.5.4- to 0.5.5+ Some minor API changes were made which shouldn't break anything but I list them to be on the safe side.

0.5 to 0.6 No changes in public API, only additions.

WARNING: In version 0.4.0, I forgot to move lHTTPSettings unit from lib to the http example. It was NOT supposed to be a part of the library, just the example. DON'T use this, it's not a "library", it's a part of the example (http server will get it's own project later)

GDB crashing issue

On Linux, since you start using LNet, GDB can crash randomly (upon compilations) with diverse kind of reports. Setting debugger to Automatic in both lnetbase and lnetvisual package's options fixes the issue.