Berkeley sockets
The Berkeley sockets application programming interface is a library for developing applications in the C programming language that access a computer network. Berkelet sockets, also known as the BSD socket API originated with the 4.2BSD system (released in 1983) as an API for development of sockets that was covered under the BSD license. It was not until 1989, however, that Berkley was able to release a version of it's operating system and networking library free from the licensing constraints of the Open Group's copyright protected UNIX operating system.The Berkley socket API is the de facto standard abstraction for network sockets. Most other programing language use a similar interface as the C API.
| Table of contents |
|
2 The client side 3 The server side 4 Blocking vs. NonBlocking |
Berkley sockets are capable of two modes of operation. A blocking socket will not "return" until all the data has been sent, or received.
This may be a problem if a socket is listening, as it may hang a program as the socket waits for data that may never arrive.
See also:
The Header Files
There are many header files associated with the Berkeley socket development library. They are as follows:
Definitions for the most basic of socket structures with the BSD socket API
Basic data types associated with structures within the BSD socket API
Definitions for the socketaddr_in{} and other base data structures.
Definitions and data type declarations for SOCK_UNIX streams
The client side
socket()
gethostbyname() and gethostbyaddr()
connect()
The server side
socket()
bind()
listen()
accept()
accept() is used to to satisfy a connection request from a remote host. A specified socket on the local host (which must be capable of accepting the connection) is connected to the requesting socket on the remote host. The remote socket's socket address is returned.Blocking vs. NonBlocking