lNet

From Lazarus wiki
Revision as of 15:53, 13 November 2005 by Almindor (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

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, lThreadNet library for multithreading and lNetComponents libraries for providing visual and non-visual components for networking.

These components were tested in Win32 and Linux. They should however run on any major platform supported by FPC. Homepage of the lNet base libraries is: [url]http://members.chello.sk/ales[/url]

Author

Ales Katona (User: Almindor)

License

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

Download

TODO

Change Log

  • Version 0.1.0 12.11.2005

Roadmap

  • Stress testing
  • Addition of input and output streaming classes/components
  • Addition of Telnet components

Dependencies / System Requirements

  • Lazarus 0.9.10 (FPC 2.0.0)

Status: Alpha

Issues: Tested on Windows (WinXP) and Linux (Kubuntu Breezy Badger).

Installation

  • In the lazarus/components directory, unzip the files from lnetpackage-<version>.zip file. The lNet folder will be created.
  • Open lazarus
  • Open the package lnetpackage.lpk with Component/Open package file (.lpk)
  • Click on Compile
  • 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.

Usage

Drop a TLTCPComponent or TLUDPComponent on a form. Assign OnAccept, OnError, OnRecieve and OnDisconnect event handlers. Note that this is optional but in most cases required for functionality. Note also that if you don't assign OnError it will throw an exception in such case when a connection error occurs.

Optional properties you may set are:

  • Buffersize - this is the maximum size a buffer can hold per-one recieve (note that assigning big number may produce random result. OS buffer is limited to 65k normaly)
  • MaxMsgs - this is the maximum number of messages a recieve buffer can hold. It's a security limit.

Client connection is initialized with the Connect call. Arguments are IP address/hostname and port respectivly. Server connection is initialized with the Accept 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 SendMessage method. Arguments are data to be sent in string form.

Note: Currently the components are limited. I will add input and output classes/components for better handling later.

Events of TLNetComponent class.

  • OnError - this event is fired whenever a connection error occurs. If no handler is assigned an excepion with "Data" is raised. Arguments are: Data - contains string and numerical representation of error message formatted in native encoding or UTF8 (depending on ForceUTF8 property). SocketNumber is the internal number of socket at which the error occured, -1 means "not an error on socket".
  • OnAccept - this event is fired whenever a connection is accepted on a server. If no handler is assigned nothing is done. Data contains the informational message in english. SocketNumber contains the internal number of socket which accepted the connection.
  • OnDisconnect - this event is fired whenever a connection is lost. If no handler is assigned nothing is done.

Data contains the informational message in english. SocketNumber contains the internal number of socket which got disconnected.

  • OnRecieve - this event is fired whenever new data is recieved. If no handler is assigned nothing is done, but a system buffer fill may happen which will in turn fire an OnError event. Data contains the recieved data. SocketNumber contains the internal number of socket at which the data got recieved.