使用独立桌面的 RMI 应用程序

RMI app using standalone desktop

我正在开发一个应用程序,其中桌面将用作服务器(因为该应用程序的用户很少),我正在使用 java rmi 技术在多个客户端和 server.the 独立桌面在网络下,它会受到攻击。而 运行 服务器 class 我收到这样的错误: 连接拒绝主机:本地主机;嵌套异常是: java.net.ConnectException: 连接被拒绝 下面是我使用的示例代码--

  import java.rmi.*;
import java.rmi.registry.*;

public class MyServer{

public static void main(String args[]){
try{

Adder stub=new AdderRemote();
Naming.rebind("rmi://10.123.56.78:5000",stub);

}catch(Exception e){System.out.println(e);}
}

}

在 10.123.56.78 端口 5000 上没有侦听 RM​​I 注册表(或其他任何东西)。

事实上,当调用 Naming.bind()/rebind()/unbind() 时,根本没有必要指定 IP 地址,因为您只能在本地注册表上执行这些操作。在这些情况下,仅指定 "localhost" 更有意义,它也使您的代码具有可移植性。

为什么要使用端口 5000?