I am reading API I have got the following methods and descriptions.
getServerPort : Returns the port number to which the request was sent getServerName : Returns the host name of the server to which the request was sent.
getRemotePort : Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request. getRemoteAddr :Returns the Internet Protocol (IP) address of the client or last proxy that sent the request getRemoteHost: Returns the fully qualified name of the client or the last proxy that sent the request.
getLocalName:Returns the host name of the Internet Protocol (IP) interface on which the request was received. getLocalPort :Returns the Internet Protocol (IP) port number of the interface on which the request was received. getLocalAddr : Returns the Internet Protocol (IP) address of the interface on which the request was received.
Server represents server Remote represents client
What about Local?
SCJP 5 |SCWCD 5| Started thinking about Web Services ?
Joined: Mar 22, 2005
Why not write a simple servlet and print those values to the console? That should provide an answer in minutes.
The hint is that server assigns a different port for communication once it has accepted the connection.
e.g. A service is listening on port 100 and it accepts a connection from a user. Now further data transfer may be made through port 110 as 100 is used for listening to other users' request (you don't want a server that serves single user at a time)
Now read the servlet specification for more clarity on what does local represent.
hi, Local and server both are technically same,but differ logically in the function it does.Both of them are remote to client as said earlier.Addressing your query,Server may be thought of possessing many logical ports.Local here represents the port on which requested service is provided .On the other hand server port receives the incoming request but doesn't provides any response in reply to request !