What is socket?
A socket is one endpoint of a two-way
communication link between two programs running on the network. The application
creates a socket. Socket is an interface between application layer and
transport layer.
It is an interface (a “door”) into which an
application process can both send and receive message to/from another
application process (remote/local application process). Socket is also referred
as the application programmer’s interface (API) between the application and the
network.
Need of Socket
When we desire a communication between two
applications possibly running on different machines, we need sockets. Requirement
of socket is to build any Network Application i.e., Web browsers, FTP etc…
How Socket Works?
There are two different programs running on
two different machines in network. Client program wants to communicate with
server program. Client select any free port from client machine and send data
to server process. Server select port which is bind with particular server
process. That port is called agreed or specific port. After that logical
connection is created between client and server. Server received client process
at agreed/specific port. Then communication is started between server and
client.
What is Socket address?
Socket is combination of IP address and Port
number. IP address is used for host-to-host communication in network. IP
address is assigned by network layer. Port number is used for process-to-process
communication in network. Port number is assigned by transport layers protocol.
How process can identify using socket?
Let’s take one example, there is one Server
host and Client host in above diagram. There are two different servers are
configured on server host. Client send a request message to server. Request
message is received from port number 80. At server-side Web server is bind with
port number 80. So, Sever OS forward that request message to Web server. Process
is identify based on port address. Port address is already assigned in unique
socket address.
On which layer socket is execute in TCP/IP Model?
Socket is executed at transport layer in TCP/IP
as well as in OSI model. Socket address is combination of IP address and port
number. Port number is assigned by transport layer protocol either TCP or UDP.
Port address is used for process-to-process communication in network.
Types of Sockets
There are two types of sockets: Stream
Socket and Datagram Socket.
Stream Socket
Stream socket is also called connection-
oriented socket. It provides reliable, connected networking service. Error
free; no out- of- order packets (uses TCP). Applications of Stream Sockets are
telnet/SSH, http, https and many more.
Datagram Socket
Datagram socket is also known as
Connectionless socket. It provides unreliable, best- effort networking service Packets
may be lost; may arrive out of order (uses UDP). Application of Datagram
Sockets are streaming audio/ video (real player) and many more.
Raw Socket, Sequenced packet Socket etc.
To learn more about Introduction of Socket, Click here
Watch more videos click here.
👏🏻 sir please upload more content on this topic
ReplyDeleteThank you so much....Please share with others....
Delete