Macintosh Development

The MIT Sockets Library was a CFM shared library which emulated the BSD sockets
networking API (as defined in UNIX Network Programming: Volume 1 by W. Richard Stevens)
on top of Open Transport (Apple's XTI Streams-based networking layer).
Sockets provided not only the networking calls themselves, but the IP address,
hostname and service manipulation functions normally used by BSD sockets applications.

What are Sockets?

BSD Sockets originated in the Berkely UNIX distribution and are a method of communcaition between
a client and a server. Sockets represent an "application protocol" for communication. The actual protocol
for communication may be TCP, IP, Ethernet, or local UNIX protocols and the identity of the client and
server depend on the actual form of protocol. In the context of this library, clients and servers are
networked computers communicating via TCP/IP. The application level protocol hides these details from the
programmer and allows us to write to a common API.

Should I use the MIT Sockets Library?

Generally, no. The Sockets Library was developed because we needed a lightweight Sockets implementation
that could be called from a CFM shared library on Mac OS 8 and 9. It was not intended as a general-
purpose solution for third party developers. Also, we are no longer maintaining, using, or
supporting SocketsLib, since we now use the sockets functionality built into Mac OS X.
There is no Mach-O version of SocketsLib. CFM callers on OS X can access the SocketsLib via
the CFM interface installed by the Mac OS X Kerberos Extras.

If you are looking for a sockets solution, we suggest you consider GUSI,
the Grand Unified Socket Interface, or the BSD sockets API provided by Mac OS X.

How do I use the Sockets Library?

The Sockets library was intended for use as a compatibility library for porting
existing Unix clients. The sockets library does not provide server functions
such as listen() and accept(). Because the sockets support
is not complete (although the functions it does provide are robust), we recommend
that you write directly to the OT API for servers or new client applications.

The Sockets Library provides support for both single and multithreaded applications through
use of the Idle Library.
In a single threaded application, the libraries call WaitNextEvent()
periodically when a socket is blocked on the network. This gives time to other applications.
The Idle Library also provides an event handler callback system for responding to cancel events
and window updates. In a multithreaded application, the Sockets Library uses the Idle Library
to periodically call YieldToAnyThread() whenever a sockets API function is blocked
on the network. When using the Sockets Library in a multithreaded application, an application
should never call Sockets Library functions from your main thread.

Differences between the sockets library and the BSD implementation

As mentioned above, the Sockets Library is not a complete BSD sockets implementation. In addition, several
important differences exist between the Sockets Library and BSD. Notably: the MIT sockets library does not
support errno. Instead, GetMITLibError() should be used. In addition the BSD sockets
API functions (read(), write(), fcntl()) are renamed to
socket_read() etc. These functions behave in the same way as their BSD counterparts despite
the name change. In addition, the error codes returned by some functions (notably socket_connect())
may differ slightly from those documented in [Stevens]. Consult the SocketErrors.h file to resolve these
differences.

Where is the API specification?

Please refer to the SocketsLib API for a list of the
available functions and how to use them.

Where do I get SocketsLib?

The SocketsLib SDK is part of Kerberos Support Library in Kerberos for Macintosh 4.0.3.
You can get Kerberos for Macintosh 4.0.3
here.