Next: Remote Procedure Call (RPC)
Up: Client/Server Systems
Previous: Client/Server Systems
Sockets
Figure 3:
A socket connection.
|
- Sockets are used to provide the capability of making connections from one application
running on one machine to another running on a different machine.
- A socket abstraction consists of the data structure that holds the information needed
for communication, and the system calls that manipulate the socket structure.
- Once a socket is created, it can be used to wait for an incoming connection (passive
socket), or can be used to initiate connection (active socket).
- A client can establish an active connection to a remote server by creating an
instance of a socket. To establish a server connection and bind it to a particular
port number, we should create an instance of a server socket.
- A server socket listens on a TCP port for a connection from a client (passive socket). When a client connects to that port, the server accepts the connection (see Fig. 3).
- Once the connection is established, the client and server can read from and write to the socket using input and output streams. Streams are ordered sequences of data that have a source (input stream), or destination (output stream). Once the client or server finishes using the socket, the socket structure is deallocated.
Next: Remote Procedure Call (RPC)
Up: Client/Server Systems
Previous: Client/Server Systems
Cem Ozdogan
2006-12-27