I am creating TCP socket application. In server side,
ss = new ServerSocket(10000);
Socket socket = ss.accept();
String remoteIp = socket.getInetAddress().g
socket.getInetAddress()
returns an InetAddress
object that contains the IP address of the remote machine.
InetAddress.getHostAddress()
returns a String
object with the textual representation of that address.
So, to end up with a String
you can print, that's how you do it.
Edit: In case you're not familiar, this is called 'method chaining'. It's the same thing as saying:
InetAddress addy = socket.getInetAddress();
String remoteIp = addy.getHostAddress();
In addition to Brian Roachs answer:
You can also take a look into the Java API to find a description for classes, methods and fields: