L3 Port & Socket
L3 Port & Socket
1
q Port & Socket:
Ø The main difference between the socket & port is that the socket
2
Ø A computer network is a collection of multiple devices connected
these devices send and receive message into and out of the network
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 ?
7
q What is a Socket ?
8
Ø In a real-word scenario, a port is similar to the
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).
18
Ø Solution :
19