我如何从 localhost 获取套接字连接的 ip?
我试试这个:
ServerSocket ss = new ServerSocket(1919);
Socket test,s = new Socket("127.0.0.1",1919);
test=ss.accept();
System.out.println("we connect ");
InetAddress IP=test.getInetAddress();
System.out.println("IP of my system is := "+IP.getHostAddress()+"----"+IP);
输出 :
IP of my system is := 127.0.0.1----/127.0.0.1
但我需要: IP:192.168.0.XXX
谢谢