tags:

views:

63

answers:

1

How could a possible vendor implementation of HttpServletRequest.getRemotePort() get the remote port ? Is it parsed from the actual request sent ? I could not see any request headers like "Client-port", "Request-port" or the like.

+1  A: 

The Web server receives the client's request using the normal mechanisms of TCP/IP. The client host and port are among the information that's available at that level. Having established the connection, the server packs it into the request information passed to your program.

The client doesn't send its port number, and even if it did it would be of dubious value because it would be very easy to fake for mischievous purposes. The port number is sent as part of the packets exchanged by TCP/IP stacks.

Carl Smotricz
Oops ! Forgot that Http works on top of TCP/IP. :)
divesh premdeep