[英]How can I get the Client IP of the java RMI programming?
Can anyone explain how I can get the client IP of the Java RMI programming, including a sample of how to use it? 谁能解释我如何获得Java RMI编程的客户端IP,包括如何使用它的示例?
I have looked up the Java API , but it is hard to understand. 我已经查看了Java API ,但很难理解。
I would like to print the client IP on server 我想在服务器上打印客户端IP
The only method in the RemoteServer
class that you ever need to call is getClientHost()
. 您需要调用
RemoteServer
类中的唯一方法是getClientHost()
。 That's the one that does what you asked about in your title. 这就是您在标题中要求的内容。
I found the solution and what you guys meaning, thanks: 我找到了解决方案以及你们的意思,谢谢:
We need a try-catch to handle the getClientHost() function in the interface implementation of server. 我们需要一个try-catch来处理服务器接口实现中的getClientHost()函数。
Here's the code: 这是代码:
try{
System.out.println(getClientHost()); // display message
}catch(Exception e){}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.