Skip to content Skip to sidebar Skip to footer

Java Servlet Returns Remote Port Of 0?

I'm using a servlet deployed on Google AppEngine to respond with the client's remote port number. HttpServletRequest.getRemoteAddr() works fine, but getRemotePort() returns 0? Por

Solution 1:

I'm not sure why getRemotePort would return 0, but for your end goal knowing the client port is useless. The client port gets reassigned for every connection. In fact, if the first connection uses 55046, the whole point of the client port is for a new connection to use a different, and unused client port number.

This makes it useless information for configuring a hole in the firewall policy. You will not need the client port. What you need is the server port, the server address, and optionally the client address if you only want to allow access from that client address.

Post a Comment for "Java Servlet Returns Remote Port Of 0?"