Hey guys,
Here's the problem I have:
I am writing a server application in Java using the ServerSocket and Socket classes. I have an instance of ServerSocket which listens for connection and accepts them. The server runs a website that requires users to log in using an e-mail and a password. Everything works fine until I tried it on my local network at home - I am using a wireless router for 3 computers and they all share the same IP address and differ by their local address, e.g. one is 192.168.1.1 and another is 192.168.1.2, etc. The problem is that whenever I call
...
Socket s = null;
while ( true ) {
s = socket.accept();
System.out.println( "ADDRESS: " + s.getLocalAddress().getHostAddress() );
...
}
it prints my current local address (192.168.1.2) even when I enter the website from one of the other computers, which means that I can log in from one pc and I would automatically logged in the others as well, since I am using the local address as a unique identifier for each connection.
My question is: is that the correct way to get the local IP and why is it printing the same address even when I am loading the site from a different computer?
Thanks. (pls let me know if you need to know anything else)