I need to know the clients ip addresses, Here is my cod
public static void main(String[] args) throws Exception {
server = HttpServer.create(new InetSocketAddress(8000), 0);
server.createContext("/", new MyHandler());
server.setExecutor(null); // creates a default executor
server.start();
System.out.println("Client ip is: " + server.getAddress().getAddress());
}
handler:
public static class MyHandler implements HttpHandler {
@Override
public void handle(HttpExchange t) throws IOException {
t.getRemoteAddress().getAddress(); // t is 0:0:0:0:0:0:0:
}
}
Result:
Client ip is: /0:0:0:0:0:0:0:0
Why i cant get real clients ip?