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,
- 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),
- 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.
- 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.
Cem Ozdogan
2010-12-20