Reputation: 75
I just started learning networking and at the moment I am covering the OSI and TCP/IP models.
A question that bothers me regards decapsulation and encapsulation of data.
If I send an http request for example, the TCP header adds the source port of the client browser that asked for the page. When the message arrives at the server, at every layer it decapsulates the data. When and where does is save the source port and ip address to later put them as the destination address for the response?
Upvotes: 0
Views: 30
Reputation: 310860
The connection endpoints are permanently associated with the socket handle inside the TCP stack. You can query these values using the getsockname()
and getpeername()
functions.
Upvotes: 1