I believe in sharing code. When I have something that’s up to snuff, and I think can help other programmers, I believe in spreading it around. That’s what the programming community is all about (or, at least, should be).
Back in 1998, I wrote a small package of routines for programming for the internet under Virtual Pascal for OS/2. Over the years the library grew, I moved to Windows, and I moved from the now-discontinued VP to Free Pascal (as did most other Pascal programmers). The library kept evolving over time.
Recently, while working on my still-in-progress “Scooter” podcatcher (which hopefully I will finish one of these days), I adapted the library to the “class” model for objects as defined by Delphi and adopted by FPC. With nothing better to do the past few days I went in, polished up the code a bit, finally wrote some documentation (in the form of HTML help as used by FPC), and have decided to put it out there.
Briefly, what this unit does is create an object class called TSocketObj, which allows you to create and use socket connections over TCP/IP in programs created by Free Pascal. This encapsulates and greatly simplifies the techniques normally used in Winsock programming. There’s also an implementation of TStream called TSocketStream, which lets you use Internet connections the same way you would use memory or file streams, and a descendant of TSocketObj specifically for retrieving files from web servers using HTTP GET calls. Until you try it, you won’t believe how easy it can be for your program to grab a file off a webserver.
The code may be freely redistributed as long as my notice remains in the source code. Programs compiled with this code may be redistributed as long as credit is given.
If you’ve come up with an improvement or new version of this unit, please let me know.
If you want to, you can grab it here: SocketClasses for Free Pascal

Recent Comments