Saturday, November 27, 2010

Sockets

Sockets

  • Socket is one end of a two way communication link between two programs running on a network.
  • Data can be passed between different processes by connecting the two sockets together

Basic socket types

  • Stream Socket
    • Connection oriented sockets
    • Consists of a stream of bytes that can be bi-directional
    • Usage of stream sockets is a more reliable method than the usage of datagram sockets
  • Datagram sockets
    • AKA Connectionless sockets, no explicit connection is established
    • A message is sent to a specified socket and can be received appropriately from the specified socket
    • Usage of datagram sockets is reducing the overhead incurred by establishing an explicit connection

Row sockets

  • Generalized form of sockets called row sockets
  • Packet is passed directly to the application that needs it bypassing the mechanism by which the computer handles TCP/IP

Ports

  • Defined to solve the problem of communicating with multiple operations simultaneously

Sockets composed of
  • IP address of the machine
  • Port no used by TCP application

Socket numbers are unique across the entire internet as IP address is unique across the internet and the port no is unique on the individual machine. This enables process to communicate with another process across network based entirely on socket number.

Client Server applications uses sockets

  • Server waits for the connection from the client
  • Client initiates the connection with the server
  • Server should be already running before client tries to connect
  • Client must know the target address and the port no, tries to establish a connection with the server
  • Server accepts the connection
  • Server application creates a new socket to deal specifically with the connected client
  • Server and client communicate by reading from and writing to their respective sockets

No comments :

Post a Comment