written 2.6 years ago by | • modified 2.6 years ago |
written 2.6 years ago by |
Solution
The Two systems communicate with each other over a network by establishing a socket.
Each end point (usually a client who starts a request) and server (which receives the request) binds a local port to use for the connection.
The port number does not have to be unique per connection.
For example, web servers listen on port 80 by default. That way, clients know that if port 80 is open, the service behind it is probably a web site.
From the client’s perspective, the connection’s destination port is 80.
The client needs to open its own port, which is the source port of the connection.
When the server receives a request, it knows to respond to the client’s port number.
In network programming, the core functions used to communicate between servers are bind, listen, connect, accept, and send.
These functions establish connections over TCP/IP (or other protocols, if the system supports them).
TCP :
Transmission Control Protocol (TCP) is a connection-oriented protocol that handles traffic in a reliable manner.
There are two important concepts: connection-oriented and reliable.
The connection-oriented aspect of TCP means the protocol maintains a state between its two end points that indicates whether communications are beginning, data is being transferred, or the communication is finished.
The reliable component to TCP ensures that data is successfully transferred between the end points. It uses sequence numbers to make sure each end knows how to put data in order, and when to re-request missing data.
UDP :
The User Datagram Protocol (UDP) is a connectionless protocol that essentially dumps data onto a network without requiring confirmation from an end point that data was received in any particular order or that it was received at all.
The lack of confirmation makes it an unreliable protocol.
UDP has less network overheads than TCP and its packets require less processing. It is often used in high-throughput applications like gaming or streaming media where missing a packet or two would not negatively affect the overall quality of the content.
However, these features also weaken UDP’s security against spoofing attacks.
Answer already present in Ques10, avoid these questions.