[fpc-pascal] Basic Sockets in FreePascal
Mark Morgan Lloyd
markMLl.fpc-pascal at telemetry.co.uk
Sun Jul 26 17:47:52 CEST 2015
Michael Van Canneyt wrote:
> On Sun, 26 Jul 2015, Coyo wrote:
>
>> I have read on the wiki and documentation that FreePascal does not
>> have any native support for socket handling, and that you need an
>> external third party library to have any support for it.
>
> This is not correct. Of course Free Pascal has native support for socket
> handling ?
Knowing the URL of that wiki page would be useful, so that we can fix it
if it really is broken. What version of FPC is the documentation for?
>> I want to write an IRC bot in FreePascal, but I need the ability to
>> both make outgoing connections to IRC servers or other bots of the
>> same kind, as well as accept incoming connections from other bots.
>>
>> I'd prefer as straightforward TCP sockets support as I can get. Any
>> advice would be greatly appreciated. Thank you in advance for your
>> time and patience.
>
> Just use the sockets or ssockets units. The first is plain pascal and a
> straightforward interface as you encounter it in any C implementation,
> the second is using classes.
Seconded, it's something I do on a regular basis when I have to do
something with a non-standard protocol. However I think there's a couple
of points worth considering.
The first is that the Pascal /language/ doesn't have implicit support
for sockets, you need to import an appropriate unit/library. That's
going to be the case for almost all general-purpose languages, with the
exception of things like Perl and Python which try to build in
everything a programmer might need including the kitchen sink.
The second is that for standard protocols like FTP and HTTP it might be
better to use a third-party library to avoid reinventing the wheel when
it comes to security etc., some of these- for example Synapse- are
routinely used by almost everybody but aren't packaged with FPC because
their developers prefer to stay independent.
--
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
mailing list