将 RMI 限制为一个端口的含义 [英] Implications of restricting RMI to one port

查看:57
本文介绍了将 RMI 限制为一个端口的含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够将我的应用程序使用的端口限制为一些尽可能小的已知集.该应用程序使用 Java RMI 与远程服务器进行通信.注册表在标准端口 1099 上导出.但是,用于导出各种远程对象的端口似乎并不总是一致的,尽管它确实在短时间内在多个连接中保持不变.我未受过教育的猜测是在幕后进行的某种服务器套接字缓存导致了这种情况.

I'd like to be able to restrict the ports used by my application to some small-as-possible known set. The application uses Java RMI to communicate with a remote server. The registry is exported on port 1099, which is standard. However, it appears that the port used to export the various remote objects is not always consistent, though it does stay the same across multiple connections over a short period of time. My uneducated guess is there is some sort of caching of the server sockets going on behind the scenes which causes this.

我希望能够确保连接始终通过几个众所周知的端口进行,以便安装客户端应用程序的用户必须在其防火墙中打开尽可能少的端口.似乎我可以通过将 RMISocketFactory 更改为自定义实现并覆盖 createServerSocket 方法以始终使用已知端口来做到这一点.但是,这引发了一些问题:

I'd like to be able to ensure that the connection always occurs over a few well-known ports, so that users who install the client application have to open as few ports as possible in their firewall. It seems that I could do this by changing the RMISocketFactory to a custom implementation and override the createServerSocket method to always use a known port. However, this raises a few questions:

  • 这对可扩展性有何影响?如果我知道一次只能连接一个人,这听起来很棒,但它不会阻止多个同时连接吗?
  • 是否可以将这些远程对象绑定到与注册表相同的端口上?我的直觉说不,因为端口已经被 createRegistry 调用绑定了.
  • 还有其他我不知道的含义吗?

推荐答案

它不会阻止多个同时连接吗?

wouldn't it block multiple simultaneous connections?

没有

是否可以将这些远程对象绑定到与注册表相同的端口上?我的直觉说不,因为端口已经被 createRegistry() 调用绑定了.

Is it possible to bind these remote objects on the same port as the registry? My intuition says no, as the port would already be bound by the createRegistry() call.

是的,只要你在同一个 JVM 中通过 LocateRegistry.createRegistry() 启动注册表,并且只要涉及的任何服务器套接字工厂都是 equal()>.

Yes, as long as you start the registry in the same JVM, via LocateRegistry.createRegistry(), and as long as any server socket factories involved are equal().

还有其他我不知道的含义吗?

Are there other implications I am ignorant of?

完全没有影响.RMI 在具有 null 或相等服务器套接字工厂的远程对象之间进行端口共享,而 TCP 在同一端口的多个连接之间进行端口共享.

There are no implications at all. RMI does port sharing between remote objects with null or equal server socket factories, and TCP does port sharing between multiple connections to the same port.

这篇关于将 RMI 限制为一个端口的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆