In virtual hosting via IP address or virtual hosting via port number, a web server decides which web site to serve based on the IP address or port number that a request was sent to.
When a web server receives a HTTP request, how can it know the IP address and port number to which the request was sent?
Does the request contain the IP address and port number, and if yes, does the server read the IP address and port number from the request?
If not, does the web server call some function in the socket library to get the IP address and port number?
Thanks.