libsocket 0.7.1 Documentation

libsocket Documentation version 1.0.2
Last updated: 12th May 1998

Copyright

libsocket Copyright 1997, 1998 by Indrek Mandre
libsocket Copyright 1997, 1998 by Richard Dawe
Portions of libsocket Copyright 1997, 1998 by the Regdos Group

libsocket is distributed under the terms of the GNU Library General Public License (the GNU LGPL).

This document was written by Richard Dawe. Please see his contact details for (slightly) more information.


Introduction

libsocket is a BSD-socket library for DJGPP. It uses Windows's networking functions to provide TCP/IP networking services to DJGPP programs. For more detail, please see question 1.1 of the FAQ.

libsocket currently does not work with Winsock 2! This means it will not work under Windows '98.

This version has not been tested extensively, as I do not have access to all of the networking environments that the new code works with. It is very much a work in progress, hence the extra .0 version. Any feedback about when it works or doesn't would be appreciated.


Table of Contents

The following links explain various aspects of libsocket in more detail:
 
 
Availability
Bugs & To-dos
Installation
Credits
 Request for Feedback and Information
Version History
 

Please see the Library Reference (HTML versions of the man pages) and some Frequently Asked Questions (FAQ).


Availability

Where to Download libsocket

The main site for libsocket is http://irix.bris.ac.uk/~rd5718/libsocket/, but the distributions are actually on Geocities (see below). The old distribution site can be found via  http://www.pld.ttu.ee/~indrek/. There will be a link from the old site to the new site. libsocket should be downloadable from the DJGPP archive. A mirror of this as part of the Simtelnet archive can be found in the UK at ftp://sunsite.doc.ic.ac.uk/packages/simtelnet/gnu/djgpp/. If you do not know of a local mirror site, click below to download from the main distribution site:
 
Binary distribution http://www.geocities.com/SiliconValley/Lab/3216/lsck071b.zip
Source distribution http://www.geocities.com/SiliconValley/Lab/3216/lsck071s.zip
 

I know the links in this document are UK-centric. I'd be happy to make up for this, if you mail me international links.

Which Distribution to Download

If you simply wish to use libsocket in programs, download the binary version. If you're interested in how libsocket works, or you wish to modify the library, download the source distribution. If you download the source distribution, you will be able to compile a debugging version of the library.

What libsocket requires

The following DJGPP packages are required to compile libsocket's demo programs and the library: The following DJGPP packages are required to view the man page documentation: The following DJGPP packages are required to rebuild the HTML versions of the man page documentation: libsocket requires TCP/IP networking to have been installed. This can be done from the networking control panel.

 [Back]


Installation

Decompression

As of version 0.7.1, libsocket uses the contrib/ directory layout, and should be unzipped into the DJGPP directory. libsocket should be decompressed using InfoZip or WinZip or another unzipper that supports long filenames. If you do not have a long filename decompressor, then the library will still work, but some of the documentation will not be accessible (some of the man pages; some of the HTML links won't work). If you use PKZip, don't forget to use the '-d' option! All the file names in the archive will be prefixed with contrib/libsocket-<version>/, e.g. contrib/libsocket-0.7.1/, or manifest/, so it is safe to decompress into the DJGPP directory, as all the files will go into a sub-directory.

Once the library has been decompressed, changed into its directory and type "make" for a list of targets. The source distribution will have more targets than the binary distribution. To compile everything that comes with the distribution, type the following:

    make distclean
    make dep
    make all

Configuration

Please read this section carefully. It may be the case that no configuration is necessary. I realise that this is probably the least clear part of using libsocket, so if this section does not make sense or answer any of your questions, please ask me about it.

libsocket comes with a configuration program, Netsetup, that creates the configuration files. libsocket uses the same set of configuration files as Linux: hosts, host.conf and resolv.conf. These are described below, and have links to the appropriate man pages. Note that they are usually stored in c:\windows under Windows rather than /etc under Linux.
 
File
Function
hosts
"Resolving": Name to IP address translation, e.g. fred.acme.com => 192.168.0.123
host.conf
Tells the name resolver whether to look at hosts or use the DNS server first
resolv.conf
Tells the name resolver the domain name and the DNS server's IP address
 

Netsetup can be compiled and run by typing "make netsetup". It will need to know the following information:

The files created are hosts.eg, host.conf and resolv.conf, all in the setup/ directory. They need copying to a directory where libsocket will find them on start-up. You can specify this directory using the LIBSOCKET environment variable, e.g.

    SET LIBSOCKET=C:\NETCONFIG

at the DOS prompt, or in autoexec.bat, or a line in djgpp.env in your DJGPP directory (see the DJGPP FAQ for more details). If you do not specify it, the Windows directory is searched. When copying these files, don't forget to back-up the old hosts file, and don't forget to rename hosts.eg to hosts.

Note: If you configured libsocket using an earlier version of libsocket, then please reconfigure it with the latest version of Netsetup - there may have been bugs in the older version (see Netsetup bugfix 1, 2).

To test the configuration of the library, try running one of the demos, e.g. the name resolving program resit. Try:

    demo\resit <your computer name>

This should display the IP address you gave Netsetup.

libsocket can also determine some settings from the Registry. It can determine the DNS server's IP addresses from the registry in the following circumstances:

  1. the DNS server(s) IP addresses have been set in the networking control panel for a permanent network connection;
  2. the computer is using dial-up TCP/IP access with static (fixed) DNS server IP addresses.
In these cases, Netsetup does not need to be run. Netsetup requires the computer's name only to set-up the hosts file - libsocket can determine the host-name automatically.

Netsetup is probably most useful on private networks where there is unlikely to be a DNS server.

Using the Library in Other Programs

Before the library can be used in other programs, the header files (include files) and library must be copied to the DJGPP directories. This can be done by typing "make install". Then, using the library in a program is simply a matter of including the correct files (e.g. "#include <socket.h>") and linking in the library with the "-lsocket" option on the linker line.

Using the man Pages

To install the man pages, type "make installman". To view the main libsocket man page, type "man libsocket".

 [Back]


Request for Feedback and Information

If there are any features you'd like in libsocket, or you have any comments about the library, the documentation or anything to do with libsocket, please mail me, Richard Dawe, and I'll try and help.

Also, if anyone has any information about using Winsock 2 from a DOS box, then I'd be very grateful to hear how. The lack of Winsock 2 support is currently the largest problem facing libsocket.

 [Back]


Bugs & To-dos

[Indrek] There are some (there must be), but I don't have anything very nasty in mind. Most bugs are misfeatures, which means some things don't work as they're supposed to. [Rich] Here are some things I plan to add when I have time:  [Back]


Credits

General

Dan M. Hedlund <hedl0036@tc.umn.edu> http://www.geocities.com/SiliconValley/Peaks/8523/
    His Wsock library is the base of this library.

Alfons Hoogervorst <alfons@hoogervorst.demon.nl> http://www.hoogervorst.demon.nl/
    His dsock library helped to get select() and blocking recv() calls work. He also contributed some information on how to obtain Windows machine and DNS IP addresses.

The Regdos Group <alfons@hoogervorst.demon.nl> http://www.hoogervorst.demon.nl/
    They contributed the registry-access code that is used to automatically find out some IP settings. Alfons is the maintainer.

George Foot <george.foot@merton.oxford.ac.uk> http://users.ox.ac.uk/~mert0407/
    He pointed out a bug in Dan Hedlund's code.

Indrek's Credits

Linus Torvalds
    Linux is the best OS - much of the code is from it.

Richard Dawe <rd5718@bristol.ac.uk> http://irix.bris.ac.uk/~rd5718/
    This man made 99% of the documentation of this library. I can't describe him in words, magnificent guy! You'll get far, Rich. [Rich: Please, you're making me blush! =) ]

Heiko Jappe <hej@gis.de>
    He has a very nice habit of finding all the nastiest bugs and reporting them. There would be some very bad "features" in the library without him.

Wojtek Galazka <wgalazka@chem.uw.edu.pl>
    He pointed out some bugs and has some great ideas. A man with an open mind.

Rich's Credits

Indrek Mandre <indrek@warp.edu.ee> http://www.pld.ttu.ee/~indrek/
    Thanks to Indrek for writing the library in the first place, letting me contribute to it, and then, gulp, trusting me to look after it. This man has a lot faith and trust! I hope I do a good job, Indrek.

Discredits

Indrek's Discredits

Bill
    The worst OS I've ever seen, it's slow, it crashes all the time and it looks ugly. [Rich: Well, it only crashes for me when I use Microsoft applications!]

 [Back]


Version History

Version 0.7.1 1998-5-12

Version 0.7.0 Work-in-progress 1998-5-3

Version 0.6 1997-12-02

Version 0.5 1997-10-11

Version 0.4 1997-09-15

Version 0.3 1997-08-28

Version 0.2 1997-08-22

 [Back]



This document was written by Richard Dawe. His home page can found at http://irix.bris.ac.uk/~rd5718/ and his e-mail address is rd5718@bristol.ac.uk.