0
我想從本身獲取客戶端的remoteAddress。我可以使用以下方式成功連接服務器:如何在Netty Framework中獲取客戶端的本地IP地址?
b.connect(this.hostAddress.getHostAddress(),this.port).sync(); // b是Bootstrap對象
爲了簡單起見,我使用了SimpleChannelInboundHandler。
我想從本身獲取客戶端的remoteAddress。我可以使用以下方式成功連接服務器:如何在Netty Framework中獲取客戶端的本地IP地址?
b.connect(this.hostAddress.getHostAddress(),this.port).sync(); // b是Bootstrap對象
爲了簡單起見,我使用了SimpleChannelInboundHandler。
在處理程序中,你會做ctx.channel().remoteAddress()
。當使用連接時,您可以使用f.channel().remoteAddress()
它返回服務器的'SocketAddress'而不是客戶端的本地套接字。 – Neil