mat@zeus.opt-sci.arizona.edu (Mat Watson) (04/29/91)
***** Simple Socket Library ******* by Mat Watson and Hubert Bartels The Simple Socket library is intended to simplify programming with BSD sockets, by providing a set of functions which mimic the stdio library. The basic data type used by the library is the SOCKET, which is analogous to the stdio FILE data type. Here's a comparison of some code fragments to illustrate the similarities: --Normal file IO-- --Using Simple Sockets-- #include <stdio.h> #include <ss.h> ... ... FILE *fp; SOCKET *sp; ... ... fp = fopen("foobar.dat","r"); sp = ConnectSock("whereami.edu",4010) ... ... fgets( buffer, 99, fp); SockGets( buffer, 99, sp); The calls which open and close the sockets themselves hide many of the gory details associated with using sockets, and provide a more natural interface. The call to ConnectSock() above takes two arguments: a host name, and a port number. Which is a good deal simpler than the series of steps one normally takes to establish a connection using standard system calls. As is the case with most other routines that simplify a complicated process, the Simple Socket Library makes certain assumptions about how one wishes to use sockets to communicate. This library assumes communications using 'streams' as opposed to datagrams, as they are quite similar to the stdio 'streams'. In addition, the library does not use ioctl() to modify socket characteristics. So if you want to make the sockets non blocking (for example), you'll have to modify the library code ( or this functionality could probably be added later ). Instead, sockets should be checked to see if they are ready to be accessed before trying to read from one. Since I don't have the time to write a bonafide manual, I put together some test/example programs that should be looked over. The file named Testing explains how to use the test programs. I also wrote the file named Notes, which gives a man page like synopsis and a short description for the library routines. The file named Install has instructions for building the library. Much of the code is based on a version of the stdio library written by Hubert Bartels. Without that code as a basis, this library probably wouldn't be here now. Thanks Hubert. If you find the code useful, have any constructive criticism, bug fixes, or suggestions for improvement, send them to me (Mat). I'm finishing up my dissertation, so don't be surprised if I'm a bit slow in replying :-). This code is know to run on a: Sun3/160, Sparc 2, Data General Aviion, and IBM risc workstation. It compiled on an ATT 3b2, but didn't run too well at all. --Mat 4/29/91 Authors: Mat Watson mat@zeus.opt-sci.arizona.edu and Hubert Bartels hgb@catalina.opt-sci.arizona.edu