User`s guide

KwikNet TCP/IP Sockets
K
A
DAK
181
5. KwikNet TCP/IP Sockets
5.1 Introduction to
KwikNet Sockets
Sockets is an application programming interface (API) which was developed for UNIX
during the early 1980s at University of California, Berkeley. It is primarily used today
for TCP programming. Dozens of books and tutorials are available for sockets
programming, one of the compelling arguments for the use of sockets.
Programmers new to sockets may observe that the sockets API seems unnecessarily
complex. The reasons are historical. Sockets were initially developed to allow
interprocess communication via streaming devices in UNIX environments. One process
would write to a connection socket and another process would read from a socket at the
other end of the connection. Sockets were meant to be a general solution for all types of
data transfer. On many UNIX systems you can actually pass a socket to the file
read()
and write() calls in place of a file descriptor.
When the Berkeley researchers wanted to extend the endpoints of the socket beyond the
host system so that processes on two separate systems could talk, they implemented TCP
(as well as other protocols) under the sockets API. The sockets API had to be extended
to indicate the type of service to be provided by the socket. The PF_INET (as opposed to
PF_UNIX) parameter in the socket() call is a vestige of this legacy.
This use of TCP as a carrier for sockets was TCP’s first major popular application outside
of the DARPA projects where it was developed. So in a very real sense, TCP owes its
widespread popularity today to Berkeley UNIX and sockets.
Over the years, many simpler, cleaner TCP APIs have been proposed. However, by the
time TCP became popular on non-UNIX platforms, it was too late. Programmers had
become accustomed to the API and sockets had become the de-facto standard for TCP
programming.
KwikNet Procedure Descriptions
Each procedure in the
KwikNet TCP/IP sockets API is described in Chapter 5.4. The
format of each description is identical to that presented in Chapter 4.6 and used to
describe the low level services in the KwikNet Library.
However, since the KwikNet Sample Program provides a complete working illustration of
how to use each of the KwikNet TCP/IP procedures, examples are not repeated in the
TCP/IP sockets API descriptions presented in Chapter 5.4.