Let's say you're using Twitter, Facebook, Youtube, all at once. You are commenting on someone else's post on Facebook, tweeting something on Twitter and listening to a song in the background on Youtube simultaneously.
In this case, your device is connected to all three servers i.e, Twitter, Facebook and Youtube servers and also you're receiving data from all three servers at the same time.
Now, if all this data comes together, then will the device not get confused as to which data is from which server?
Similarly, if requests from multiple devices are going to a server, will the server not get confused as to which node requested which information?
Well, it does!
And to solve this problem, all devices i.e, both clients and servers are assigned Ports.
Let's take another example, In a shop, there are three different counters namely Electronics, Homecare and Clothing. These three different counters provide different services and are selling different things.
These counters can be assumed as Ports.
Different services/applications run at each port and listen to or capture the data and requests coming from each port.
Ports are classified into 2 types:
1. Hardware ports:
These ports provide a gateway to get inside a system and interact with hardware.
Eg: USB, HDMI etc
2. Software ports:
These ports provide a gateway to get inside a system and interact with software.
Every software port is denoted by a number between 0-65535.
Each software port takes us to a different application/service.
If a data packet is travelling from client to server, this data packet essentially contains four pieces of information in it.
i) IP address of the server.
ii) Port number of the server.
iii) IP address of the client
iv) Port number of the client
This combination of IP address:Port Number is known as Virtual Socket.
Comments
Post a Comment