0% found this document useful (0 votes)
12 views

L3 Port & Socket

A port is a numerical value assigned to a specific process or application to identify it and allow communication over a network. A socket is an endpoint for sending and receiving data on a specific port. It combines an IP address, port number, and transport protocol to establish a network connection between two devices and acts as an interface for network communication.

Uploaded by

rshfordmarkos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

L3 Port & Socket

A port is a numerical value assigned to a specific process or application to identify it and allow communication over a network. A socket is an endpoint for sending and receiving data on a specific port. It combines an IP address, port number, and transport protocol to establish a network connection between two devices and acts as an interface for network communication.

Uploaded by

rshfordmarkos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Port & Socket

1
q Port & Socket:

Ø The main difference between the socket & port is that the socket

is the interface of sending and receiving data on a specific port

while the port is a numerical value assigned to a specific process

or application in the device.

2
Ø A computer network is a collection of multiple devices connected

together to exchange data and share resources. The processes in

these devices send and receive message into and out of the network

through a software interface called the socket.

Ø A port is an internal addressing of the application within the device.

When a process requires communicating via the network, a socket is

created, and it is attached to a port. In brief, a socket is the

communication path to a port.


3
q Port & Socket:

Socket Port

§ An numerical value
§ An internal endpoint for
that is assigned to an
sending and receiving
application in an
data within a node on a
endpoint of
computer network.
communication.
§ Work as interface to § Helps to identify a
send and receive data specific application or
through a specific port. a process.

4
Ø Standard Application Programming Interfaces
(API) for networking :

5
q What is a Port ?

Ø The port is a numerical value assigned to every


application or a process. In communication, the data is
transmitted from a sending devices to destination
device ( receiver ).

Ø If the destination device has three application running,


the port number helps to identify the application that
requires the received data.
6
Ø A computer has a total of 65,536 ports. The port

numbers form 0 to 1023 are reserved for system usage.

Ø Port helps to identify the process the requires the


received data.

7
q What is a Socket ?

Ø The socket is the interface to send and receive data on

a particular port. It is identifier to recognize the device

in the network. When sending data, this IP address

helps to transmit the data to the correct and the port

also called the socket.

8
Ø In a real-word scenario, a port is similar to the

apartment number in an apartment building while a

socket is similar to the door of the a apartment.

Ø A port is an apartment number.

Ø A socket is the door of an apartment.

Ø An IP address is the street address of the building.


9
Ø While socket works as the interface to send and receive
data through a specific port, ports helps to identify
application or a process.

Ø Socket and port are two terms used in computer


networks, the difference between socket & port is the
socket is the interface of sending and receiving data on
a specific port while the port is a numerical value
assigned to specific process or an application in the
device.
10
q What is the difference between port and socket in
Internet terminology?

Ø A port is a communication endpoint or a specific


number used to identify a particular process or service
on a computer in a network. Ports are part of the
transport layer protocols (such as TCP and UDP) and
allow multiple applications or services to run on the
same device while distinguishing between them. Ports
are identified by numbers ranging from 0 to 65535.
11
Ø For example, when you access a website using your
web browser, the browser initiates a connection to the
web server using a specific port (usually port 80 for
HTTP or port 443 for HTTPS). The port number allows
the web server to correctly route and handle the
incoming network traffic.

12
Ø A socket is a programming abstraction that represents
an endpoint for communication between two devices
over a network. It combines an IP address and a port
number to establish a network connection. In
programming, a socket is created and used to send or
receive data between networked devices. Sockets
provide a programming interface for network
communication, allowing applications to establish
connections, send and receive data, and manage
network connections. 13
Ø Sockets are commonly used in network programming
for protocols like TCP or UDP. They allow applications
to establish connections, listen for incoming
connections, send and receive data, and handle network
communication.

14
Sockets

15
Sockets
§ A socket consists of three things:
1. An IP address.
2. A transport protocol.
3. A port number.
§ A port is a number between 1 and 65535 inclusive that
signifies a logical gate in a device. Every connection
between a client and server requires a unique socket.
§ For example:
•1030 is a port.
•(10.1.1.2 , TCP , port 1030) is a socket.

16
Ø S is a server program: let's say it's an HTTP server, so
it'll use the well-known port number for HTTP, which
is 80. I run it on a host with IP address 10.0.0.4, so it
will listen for connections on 10.0.0.4:80 (because
that's where everyone will expect to find it).

Ø Inside S, I'm going to create a socket and bind it to that


address: now, the OS knows that connections coming
into 10.0.0.4:80 should be routed to my S process via
that particular socket.
17
Ø For example: Assume you have our Upcase-client
on one host and the server on another host.

a) Suppose you run the TCP client without starting the


server. What happens exactly and why?

b) Suppose you run a UDP client without starting a UDP


server. What is different from the case of TCP and why?

18
Ø Solution :

Ø a) If you run a TCP client first, the client will attempt


to make a TCP connection with a non-existent server
process. Creating the client socket will fail.

Ø b) With UDP, the client doesn't establish a connection


with the server. Creating a socket works but sending a
datagram will fail.

19

You might also like