Difference between revisions of "lNet"

From Free Pascal wiki
Jump to navigationJump to search
(→‎About: -- new lnet url)
(→‎News: -- 0.5.8)
Line 31: Line 31:
  
 
=== News ===
 
=== News ===
 +
 +
16th of September 2007:<br><hr>
 +
 +
Released 0.5.8 as bugfix release. Bugs:
 +
* fixed crash in visual lnet package in windows if .Disconnect before .Free
 +
* fixed SMTP RFC compliance on DATA (fixed problems on some servers)
 +
* fixed/updated SMTP linebreaks (74 to 1000 and bugfix)
 +
 +
Bugfix release.
  
 
20th of August 2007:<br><hr>
 
20th of August 2007:<br><hr>

Revision as of 10:34, 16 September 2007

About

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)

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.

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)

Since 0.5.1 WinCE is considered an unstable but supported platform.

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

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.)

  • ARM/Linux fpc 2.1.4 has a bug with -O2 causing lNet to crash. Compile without optimizations on this platform.

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

16th of September 2007:


Released 0.5.8 as bugfix release. Bugs:

  • fixed crash in visual lnet package in windows if .Disconnect before .Free
  • fixed SMTP RFC compliance on DATA (fixed problems on some servers)
  • fixed/updated SMTP linebreaks (74 to 1000 and bugfix)

Bugfix release.

20th of August 2007:


Released 0.5.7 as bugfix release. Bugs:

  • fixed using of MSG_NOSIGNAL in Darwin (uses SO_NOSIGPIPE now instead)
  • fixed forgotten commit of Timeout changes from 0.5.5 (doh!)
  • introduced safety locks on CallAction against recursion

Bugfix release.

04th of August 2007:


Released 0.5.6 as bugfix release. Bugs:

  • fixed potential UDP access violation with Disconnect in rare situations
  • fixed loss of error numbers with TLSocket.Get and TLSocket.Send
  • updated linux epoll presence detection (no longer uses uname)

Bugfix release.

15th of July 2007:


Released 0.5.5 as bugfix release. Bugs:

  • fixed TCP.IterReset (now comforming to docs, see API changes for more info)
  • changed .Timeout on all components to be signed, whereas -1 now means "block indefenetly until an event happens"
  • fixed documentation errata mainly about IterNext

8th of July 2007:


Released 0.5.4 as bugfix release. Bugs:

  • fixed TCP.Count (returned always 1 before)
  • fixed UDP.Listen and UDP.Connect (caused AV in certain situations)
  • fixed potential bugs with TLSocket.Bail calls (didn't exit originating function)

25th of June 2007:


Released 0.5.3 as bugfix release. Bugs:

  • FTP active mode bug fixed
  • removed visual property Timeout (irrelevant in Lazarus/visual)
  • fixed FTP property TransferMethod (default was wrong so it never saved in OI)
  • fixed TCP Iterator bug if used right after Listen() (was nil, now points to server socket)
  • fixed LocalAddress and LocalPort values (were byte order flipped)

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:

  • fixed an oversight in WinCE visual interface (didn't work in 0.5.0)
  • fixed some potential FTP and SMTP bugs (minor)
  • added MIME support mainly for creation of complex mails to send with SMTP (attachments etc.)

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:

  • fixed some ugly UDP bugs
  • fixed windows blocking problems with visual lNet (dialogs and menus blocked our events)
  • API cleanups (WARNING: See here)
  • preliminary winCE support with Lazarus/fpc cross compilation (alpha)
  • simplified Lazarus packaging, see Installation for more info

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

  • Version 0.5.7 bugfix release regardin Darwin (MSG_NOSIGNAL was wrongly used)
  • Version 0.5.6 bugfix release regarding UDP disconnect bugs and few others
  • Version 0.5.5 bugfix release regarding TCP IterReset, and some docs. Changed timeout to signed.
  • Version 0.5.4 bugfix release regarding UDP listen/connect and TCP.Count
  • Version 0.5.3 bugfix release regarding FTP and some TCP fixes
  • Version 0.5.2 bugfix release fixing windows and winCE LCLEventer
  • Version 0.5.1 MIME support and WinCE fixes
  • Version 0.5.0 stabilization and API cleanups
  • Version 0.4.0 complete overhaul and new components
  • Version 0.3.1-1 30.01.2006 (fixed a fixes bug in Linux version, should compile now)
  • Version 0.3.1 27.01.2006
  • Version 0.3.0 (2.4.0) 16.01.2006
  • Version 0.2.0 29.11.2005
  • Version 0.1.0 12.11.2005

Status

  • Base lNet TCP/UDP - stable
  • Telnet Client - stable*
  • FTP Client - stable*
  • SMTP Client - stable
  • HTTP Client - stable
  • HTTP Server - experimental
  • MIME streams - stable

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

Roadmap

  • Stress testing [always]
  • Addition of Telnet and FTP clients (experimental level) [0.3] (done)
  • Cementing of TCP/UDP API [0.3] (done)
  • Addition of ICMP Ping/Traceroute protocol [0.4] (postponed to 0.5+)
  • Addition of SMTP, HTTP components [0.4] (done)
  • Stabilization of Telnet and FTP clients [0.5] (done)
  • Addition of MIME streams [0.5.1] (done)
  • Addition of Telnet and FTP servers (experimental level) [???]
  • Addition of SSL, FTPS [0.6+]

Dependencies / System Requirements

LNet 0.5+

  • Lazarus 0.9.22+ and FPC 2.0.4+
  • Status: Beta
  • Issues: Completly tested on Windows (WinXP), Linux (Ubuntu 6.10) and FreeBSD 5.5. FastCGI considered broken for now. WinCE requires Lazarus 0.9.23+ to compile!

LNet 0.4

  • Lazarus 0.9.18+ and FPC 2.0.4+
  • Status: Beta
  • Issues: Completly tested on Windows (WinXP), Linux (Ubuntu 6.06LTS) and FreeBSD 6.1. HTTP server has issues under high load with fastcgi usage. FastCGI works only in Linux for now.

Installation

LNet 0.5+:

  • In the lazarus/components directory, unzip the files from lnet-<version>.zip file. The lnet-<version> folder will be created.
  • Open lazarus
  • Open the package lnet-<version>/lazaruspackage/lnetvisual.lpk with Component/Open package file (.lpk)
  • Click on Install and answer 'Yes' when you are asked about Lazarus rebuilding. A new tab named 'lNet' will be created in the components palette.


NOTE: 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:

  • In the lazarus/components directory, unzip the files from lnet-<version>.zip file. The lnet-<version> folder will be created.
  • Open lazarus
  • Open the package lnet-<version>/lazaruspackage/lnetpackage.lpk with Component/Open package file (.lpk)
  • Click on Compile
  • Open the package lnet-<version>/lazaruspackage/ide/lnetidepackage.lpk with Component/Open package file (.lpk)
  • Click on Install and answer 'Yes' when you are asked about Lazarus rebuilding. A new tab named 'lNet' will be created in the components palette.


NOTE: 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

On Ubuntu lazarus components folder is "/usr/lib/lazarus/components". You must copy the lNetpackage in this folder and unzip in this folder to generate lnetpackage folder.

On this distribution your may have issues if you don't use the root account because you won't have writing rights on this folder... Activate the root account management and log in with the root account before doing any operation.

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. 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: All classes lNet units lNet units 2

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.

Note: 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.

  • OnError - this event is fired whenever a connection error occurs. If no handler is assigned an excepion with "msg" is raised. Arguments are: msg - contains string and numerical representation of error message formatted in native encoding or UTF8 (depending on ForceUTF8 property). aSocket is the socket at which the error occured, nil means that the error is not a socket specific one.
  • OnConnect - This event is fired when the client succesfuly connects. aSocket is the socket which connected. It should serve as the "start" point for clients.
  • OnAccept - this event is fired whenever a connection is accepted on a server. If no handler is assigned nothing is done. aSocket contains the socket which accepted the connection.
  • OnDisconnect - this event is fired whenever a connection is lost. If no handler is assigned nothing is done. aSocket contains the socket which got disconnected.
  • OnReceive - This event is fired whenever new data is ready to be received. If no handler is assigned nothing is done, but a system buffer fill may happen which will in turn fire an OnError event. aSocket is the socket at which the data got received. Data is read by Get/GetMessage method.
  • OnCanSend - This event is fired whenever new data can be sent again on a socket, after a call to send function failed, returning 0. It can be used to automate sending of big chunks. aSocket is socket on which send can be called.

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).

  • OnRecieve() changed to OnReceive()
  • Accept() changed to Listen()
  • All events' arguments changed. SocketNumber (int) got changed into aSocket(TLSocket) because of logical and speed reasons

0.2 to 0.3

  • Added OnCanSend and OnConnect. Connect is now non-blocking.
  • Removed buffersize and maxmsgs. Buffersize is no longer required because no internal buffer is used.

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.

  • All "connection" classes now descend from TLComponent
  • TLSocket now has a .Creator which is a TLComponent property specifying the creator (eg: TLTcp), so you can see now which socket in an event belongs to which connection.
  • Added "Connect()" and "Listen()" parameterless calls to all connections. This is mostly to enable Lazarus visual style, so people can use .Host and .Port properties and repeatedly just call ".Connect()" for example.
  • Added "StatusSet" set to SMTP and FTP components. This enables you to monitor specific FTP or SMTP actions and their results with events OnSuccess and OnFailure. You set the events to be watched in the set, and get results in one of the callbacks.
  • Changed ALL callbacks which didn't use TLSocket as sender to use it. This means all FTP, SMTP and HTTP events which had "Sender: TL<HigherType>" were reverted to basic Socket style callbacks!

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.

  • .Timeout property on eventers and connections was set to Integer (from DWord) to support -1 as "block until an event happens"

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)