| |||||||||
The Berkeley sockets application programming interface (API) comprises a library for developing applications written in the C programming language that access a computer network.
Berkeley sockets (also known as the BSD socket API) originated with the 4.2BSD system (released in 1983) as an API, covered under the BSD license, for development of sockets. Only in 1989, however, could UC Berkeley release versions of its operating system and networking library free from the licensing constraints of the Open Group's copyright-protected UNIX operating system.
The Berkeley socket API forms the de facto standard abstraction for network sockets. Most other programing languages use a similar interface as the C API.
The Berkeley socket development library has many associated header files. They include:
<sys/socket.h>
<sys/types.h>
<netinet/in.h>
<sys/un.h>
Programmers use accept() to satisfy a connection request from a remote host. A specified socket on the local host (which must have the capability of accepting the connection) connects to the requesting socket on the remote host. The code returns the remote socket's socket address.
Berkeley sockets can operate in one of two modes: blocking or non-blocking. A blocking socket will not "return" until it has sent (or received) all the data specified for the operation. This may cause problems if a socket continues to listen: a program may hang as the socket waits for data that may never arrive.
See also: Computer network
This article was originally based on material from the Free On-line Dictionary of Computing and is used under the GFDL.