Recent

Author Topic: Lnet non-Visual TCP example for MacOS and Windows  (Read 467 times)

axisdj

  • New Member
  • *
  • Posts: 46
Lnet non-Visual TCP example for MacOS and Windows
« on: July 14, 2020, 05:12:41 pm »
Hello Group,

I am planning to use the lnet library for simple TCP functionality I need in my app that I am migrating from vb6 (using winsock control)

I have learned that Lnet visual component does not work in MacOS, so I will need to use the nonVisual Method to be cross OS compatible.

I understand that events processing changes using the non-visual method and I would need to call callToAction method.

My Question: Is it 'bad' to use a timer to call callToaction? if so does anyone have a simple example using lNet for tcp communication similar to the functionality that winsock in vb6 gives me?

Any insight . examples, links will be greatly appreciated.

thanks

MarkMLl

  • Hero Member
  • *****
  • Posts: 1219
Re: Lnet non-Visual TCP example for MacOS and Windows
« Reply #1 on: July 14, 2020, 10:18:55 pm »
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

LittleBritaly

  • New Member
  • *
  • Posts: 20
Re: Lnet non-Visual TCP example for MacOS and Windows
« Reply #2 on: July 18, 2020, 11:36:34 am »
If you downloaded LNet using Online Package Manager, there will/should be a tcp example in /Users/<your user name>/.lazarus/onlinepackagemanager/packages/lnet/examples/console/ltcp/lserver.pp

I can confirm this works under High Sierra (although because of installation issues of Lnet, it wants to use the stubs debugger, it was simpler to use Codetyphon which installs the Lnet components without issue).
 
There is an issue with the Lnet Visual components on a mac, events do not seem to be fired, it was simpler to modify the lserver.pp example and use in a graphical application, than it was to try and find the cause of the visual components failure.

Hope this helps.
 

Leledumbo

  • Hero Member
  • *****
  • Posts: 8266
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Lnet non-Visual TCP example for MacOS and Windows
« Reply #3 on: July 18, 2020, 11:59:59 am »
My Question: Is it 'bad' to use a timer to call callToaction?
I wouldn't call it bad, CallAction actually gives you freedom to decide when to synchronize your events and their handlers. In a console application, the main loop usually calls this indefinitely and I have checked it doesn't eat CPU. In a GUI application, it can be synchronized to some other action, like a button press, or as you ask, a timer event.

MarkMLl

  • Hero Member
  • *****
  • Posts: 1219
Re: Lnet non-Visual TCP example for MacOS and Windows
« Reply #4 on: July 18, 2020, 12:34:03 pm »
lNet's actually fairly well-behaved: I'd not like to guarantee that it's thread-safe but it certainly appears to be fairly tolerant. Until things go wrong, and the flow-control's so complex that it's virtually impossible to find out what's happening.

It goes back to an era before threads were universally implemented particularly on unix, and until comparatively recently different targets implemented them using different kernel facilities.

The only thing I use lNet for is Telnet, e.g. to provide a debugging backdoor in a program that is otherwise not particularly network-oriented. That's one reason why the one with FPC has diverged from the one (now) on Github: the FPC one has subcommand support that I added to support the terminal type facility.

I'm very close to writing a telnet library to replace it, with the specific intention that it's completely agnostic of the use of threads etc. That would probably simply split data and commands into multiple streams and FIFOs, and leave everything else to the user.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

axisdj

  • New Member
  • *
  • Posts: 46
Re: Lnet non-Visual TCP example for MacOS and Windows
« Reply #5 on: July 21, 2020, 12:31:47 am »
Thank you Leledumbo for answering the question!

 

TinyPortal © 2005-2018