我正在使用Java 1.6中的httpurlconnection连接到url
我连接的服务器使用DNS轮循机制在多个服务器之间共享负载。
如何获得我实际连接的远程IP地址?
HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
//I then need something like this!
log(SUCCESS, "made connection to: " + urlConn.getRemoteIp());
Run Code Online (Sandbox Code Playgroud)
URL url = new URL("http://yahoo.com");
String host = url.getHost();
InetAddress address = InetAddress.getByName(host);
String ip = address.getHostAddress();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7085 次 |
| 最近记录: |