In: Computer Science
What are the functions of sockets in networked applications? Explain your answer with a case scenario where you are receiving 10 packets from a node. How will the socket perform its role?
Socket is simply the combination of an IP address and a port. More formally, a socket is " one endpoint of a two-way communication link between two programs running on the network. A socket is bound to a port number so that TCP layer can identify the application that data is destined to sent to. Coming to your next question, when you send a large over the internet,it doesn't get sent in one big chunk. Instead it gets chopped up into small manageable bits(called packets) that each find their way to intended destination. So these 10 packets will get chopped in similar fashion. The socket implemetation deals with it into packets and sending it over the network and handles resending packets that are lost on the way.The packet is fragment of information that is send through the socket.TCP makes sure that all the packets arrive in their correct destination, and can be re-ordered into the correct sequence, since the packets might take different routes to the same destination.
So to put it all back together, a socket is the combination of an IP address and a port, and it acts as an endpoint for receiving or sending information over the internet.