BSD Sockets is by far the most popular application programming interface (API). The name pays tribute to its authors – it was created at the University of California in Berkeley, originally for BSD Unix, but later it was ported to other branches of Unix and also to MacOS, MS Windows and even PalmOS. Applications of BSD Sockets are not limited to IP, although other uses have been rare. It is not an exaggeration to say that the application side of the Internet is built on this API.
It is well-known that to Unix, everything looks like a file. BSD Sockets API uses this paradigm for communication between programs. Its fundamental program object – the socket – represents a communication channel through which two programs can exchange data using standard file descriptors.
Even though the original BSD Sockets API was designed as protocol-independent, the astronomical size of IPv6 addresses was something that apparently exceeded even the wildest dreams of its developers. Data structures of the original BSD Sockets left some space for protocol addresses longer than the 32 bits of IPv4, not enough though to accommodate the quadruple of that size and other information that is needed for IPv6. It was thus necessary to update and extend the API. The IPv6 working group at IETF utilised this opportunity for an overall consolidation and streamlining of the API. Their most recent – and hopefully more or less final – result is RFC3493 [RFC3493]. The new API enables the programmer to write applications for both IPv4 and IPv6 using a single programming framework. In addition, the IPv6 working group defined an API for advanced IPv6 applications using raw sockets [RFC3542] although the vast majority of TCP and UDP based applications will only require the API defined in RFC 3493.
We are going to describe the data structures and function using the formalism of the C language, as they appear in Unix header files. Equivalent APIs are available for most of the common programming languages and we will show some examples at the end of this section.
A detailed explanation of BSD Sockets programming is outside the scope of this section, we will mainly concentrate on the changes introduced by the new API for IPv6. Therefore, we assume the reader has at least a basic idea about the original API, which has been covered, for example, in the classic book “Unix Network Programming” [Ste97]. Other valuable sources of information are the Unix on-line manuals.
