如何检索远程IP地址?

时间:2014-03-02 08:16:47

标签: android http request handler

我正在开发一个带有集成网络服务器的Android应用程序;在我的处理程序(实现HttpRequestHandler)中我想检索远程IP地址。我怎么能这样做?

public abstract class MyHttpRequestHandler implements HttpRequestHandler {

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

1 个答案:

答案 0 :(得分:0)

你能从服务器上拔出标题吗?虽然并非始终100%准确,但请参阅本文,它有一些您可以检查的标题:

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