posted 13 years ago
Of course that code doesn't do anything useful because it just uses hard-coded addresses.
You didn't say anything about your server, which is where you would be getting these IP addresses from. So it's rather difficult to explain how to get IP addresses from your server. But since you didn't post this in any of the forums related to web applications, let me assume that it isn't a web application. Let me also assume that you have a ServerSocket and are accepting requests from it.
In which case the accept() method returns a Socket. Which has a method to get the address to which that Socket is connected. That's the address you want.
Or if my assumptions were wrong, feel free to provide information.