Question

I am developing an Android app with an integrated webserver; in my handler (implements HttpRequestHandler) I want to retrieve the remote IP address. How can I do that ?

public abstract class MyHttpRequestHandler implements HttpRequestHandler {

@Override
public void handle(HttpRequest request, HttpResponse response,
        HttpContext httpContext) throws HttpException, IOException {
 // retrieve remote IP here...

No correct solution

OTHER TIPS

Are you able to pull the headers off the server? Although not always 100% accurate, refer to this article, it has some headers you can check:

Getting the client IP address: REMOTE_ADDR, HTTP_X_FORWARDED_FOR, what else could be useful?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top