- 论坛徽章:
- 0
|
Before studying the Unix/Linux network programming(UNP), it is of importance to learn some background knowledge about UNP, such as the concept of socket, Unix standards, etc.
Berkeley socket, also called BSD sockets, is a generalized networking capability first introduced in 4.1cBSD and subsequently refined into their current form with 4.2BSD. The sockets feature is available with most current UNIX system releases. (Transport Layer Interface (TLI) is the System V alternative). Sockets allow communication between two different processes on the same or different machines. Internet protocols are used by default for communication between machines; other protocols such as DECnet can be used if they are available.
The following are some general information about Berkeley Sockets
Developed in the early 1980s at the University of California at Berkeley. There are no longer any major alternatives. Other major alternative was TLI (Transport Layer Interface). There are communications tools that are built on tool of Berkeley sockets. (E.g. RPC )
It is an API.
Its implementation is usually requires kernel code.
It is the defacto standard for communications programming.
There are higher level tools for programs that span more than one machine. RPC, DCOM and windows remoting are examples.
Used for point-to-point communications between computers through an inter-systems pipe. Namely can use the UNIX read, write, close, select, etc. system calls.
Supports broadcast. This is where the same message may be delivered to multiple systems on a network without additional overhead.
Available on every UNIX system that I know of and somewhat available in WIN32.
Build for client/server development. That is having one system provide a service to other systems. To a programmer a socket looks and behaves much like a low level file descriptor. This is because commands such as read() and write() work with sockets in the same way they do with files and pipes. The differences between sockets and normal file descriptors occurs in the creation of a socket and through a variety of special operations to control a socket. These operations are different between sockets and normal file descriptors because of the additional complexity in establishing network connections when compared with normal disk access.
Berkeley sockets support two types of communications. These sit on top of the TCP Internet datagrams.
TCP - connection oriented, stream, reliable.
UDP - connectionless, record oriented, unreliable.
Some useful links:
1.
An overview on Berkeley Sockets
:
http://phobos.ramapo.edu/~vmiller/AdvancedUnix/berkeley_socket.htm
2.
Something about Berkeley sockets, including a group of useful examples
:
http://www.ecst.csuchico.edu/~chafey/prog/sockets/sinfo1.html
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/53857/showart_421724.html |
|