I wonder people are really checking this code and the output of this code if client is using proxy!!!!
Above code will always give 127.0.0.1 that is the default localhost IP Address.
If you are using proxy then above code will not work.
What we have to do in that case is get the machine name first and find the IP address by passing the machine name like below,