[fpc-pascal] Thoughts on Shell Approach to TCP Sockets
Mark Morgan Lloyd
markMLl.fpc-pascal at telemetry.co.uk
Thu Mar 19 10:25:00 CET 2015
Coyo Stormcaller wrote:
> On 03/19/2015 02:27 AM, Michael Van Canneyt wrote:
>> If I may suggest, if you simply want to invoke a program with a socket
>> as standard input,
>> you can just use (x)inetd, it comes by default on all unix
>> installations, and does just that: it is started by init, manages
>> TCP/IP connections and spawns off a program to handle the connection
>> with the socket handle as standard input/output.
>> Why reinvent the wheel ?
> Synapse sounds interesting. an entire TCP/IP stack written in Object
> Pascal. It sounds like fun to play with, and I've actually been looking
> around for a userspace TCP/IP stack for a VPN project of mine.
I wonder if I could comment on a couple of misapprehensions. The first
one is that the bulk of the TCP/IP stack is in the operating system,
Synapse (or equivalent) isn't simply talking to a naked Ethernet device,
instead it's using a group of system calls broadly referred to as
While it is possible to write a complete stack from scratch in any
reasonably-complete programming language, and while this has been done
for e.g. embedded systems (or by idiots such as myself for
demonstration/testing purposes :-), in practice it's avoided on account
of (a) the amount of well-tested code that it would attempt to supplant
and (b) consideration of the difficulty of implementing all required
services in a single program.
Second, Pascal, in common with most modern languages, doesn't have
primitives or constructs dedicated to things like sockets. Its
primitives are generally restricted to features which are fairly
general-purpose, with everything else being added as
procedures/functions or (in modern implementations) classes... in either
case loaded from libraries decoupled from the language itself.
It's interesting to compare this with some of the original ALGOL
implementations or even with the original Turbo Pascal, which had a
large number of keywords (e.g. to control file-open modes) which were
defined as part of the language itself. Modern practice would be to make
these into enumerations, which would be passed to a function as a parameter.
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
More information about the fpc-pascal