我正在开发一个带有集成网络服务器的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...
答案 0 :(得分:0)
你能从服务器上拔出标题吗?虽然并非始终100%准确,但请参阅本文,它有一些您可以检查的标题:
Getting the client IP address: REMOTE_ADDR, HTTP_X_FORWARDED_FOR, what else could be useful?