如何在Netty框架下获取客户端的本地IP?
我想从自身获取客户端的远程地址。我已经可以通过以下方式成功连接到服务器:如何在Netty框架下获取客户端的本地IP?,netty,Netty,我想从自身获取客户端的远程地址。我已经可以通过以下方式成功连接到服务器: b.connect(this.hostAddress.getHostAddress(), this.port).sync(); // b is a Bootstrap object 为了简单起见,我使用了SimpleChannelInboundHandler。在处理程序中,您可以执行ctx.channel().remoteAddress()。使用connect时,您可以使用f.channel().remoteAddres
b.connect(this.hostAddress.getHostAddress(), this.port).sync(); // b is a Bootstrap object
为了简单起见,我使用了
SimpleChannelInboundHandler
。在处理程序中,您可以执行ctx.channel().remoteAddress()
。使用connect时,您可以使用f.channel().remoteAddress()
返回服务器的SocketAddress
,而不是客户端的本地套接字。