written 8.4 years ago by |
Socket:
- Sockets are a service provided by transport layer.
- A socket is one endpoint of a two-way communication link between two programs running on the network.
Berkeley Socket:
- Berkeley sockets is an application programming interface (API) for Internet sockets and UNIX domain sockets.
- It is used for inter-process communication (IPC).
- It is commonly implemented as a library of linkable modules.
- It originated with the 4.2BSD UNIX released in 1983.
Primitive used in Berkeley Socket:
Socket Programming:
I) Server side:
Server startup executes SOCKET, BIND & LISTEN primitives.
LISTEN primitive allocate queue for multiple simultaneous clients.
Then it use ACCEPT to suspend server until request.
When client request arrives: ACCEPT returns.
Start new socket (thread or process) with same properties as original, this handles the request, server goes on waiting on original socket.
If new request arrives while spawning thread for this one, it is queued.
If queue full it is refused.
II) Client side:
It uses SOCKET primitives to create.
Then use CONNECT to initiate connection process.
When this returns the socket is open.
Both sides can now SEND, RECEIVE.
Connection not released until both sides do CLOSE.
Typically client does it, server acknowledges.