Convert String IP to InetAddress
807603Nov 20 2007 — edited Nov 20 2007Hey guys,
I'm using sockets and need to make a new Socket which connects to a ServerSocket at a certain IP.
Socket client = new Socket(hostIp, hostPort, localIp, localPort);
The local IP I can find by using System.net.InetAddress.getLocalHost(), but for the host IP I need to use a String address and convert it to an InetAddress object. Is there any way to do this?
Also:
The server-side of my application will be running on my computer using the ServerSocket object, so I need to find my IP to use.
The problem is that I'm using a router, so when I use ipconfig in command prompt it brings up the IP of my router. I used this to access my router settings through my browser and found another IP there. Is this the IP of my modem, or my computer, or (as someone told me) possibly the IP of the computer the network was set up on (not mine).
I'm confused!
Thanks guys.
Edited by: Nienna on Nov 20, 2007 8:33 AM