简体   繁体   English

如何为RMI客户端设置静态客户端端口?

[英]How to set static client port for rmi clients?

I need a way to set a static port for rmi clients. 我需要一种为rmi客户端设置静态端口的方法。 The server uses a fixed port for it's connections but client side creates a dynamic port although I set a client socket factory. 服务器使用固定端口进行连接,但是尽管我设置了客户端套接字工厂,但客户端会创建动态端口。

The root cause I found is in the class "TCPChannel". 我发现的根本原因是在“ TCPChannel”类中。 In this class I see this code: 在此类中,我看到以下代码:

TCPEndpoint.getLocalEndpoint(0, (RMIClientSocketFactory)null, (RMIServerSocketFactory)null);

This clearly won't work as this code is unaware of my socket factory. 这显然不起作用,因为此代码不知道我的套接字工厂。 Obviously this class is not RMI specific. 显然,此类不是RMI特定的。

Question is - is there a way to override the tcp socket creation such that it doesn't create dynamic ports at all? 问题是-是否有一种方法可以覆盖tcp套接字创建,使其根本不创建动态端口?

client side creates a dynamic port although I set a client socket factory. 尽管我设置了客户端套接字工厂,但客户端却创建了一个动态端口。

You set it how? 您如何设置? Whatever you did, you didn't do it correctly. 无论您做什么,都做得不正确。

But why do it at all? 但是为什么要这么做呢? There are lots of disadvantages. 有很多缺点。 For one thing, it will cause all RMI calls from that client to be sequentialized, possibly at two-minute intervals, or possibly cause any calls at more frequent intervals to fail with BindExceptions . 一方面,它将导致来自该客户端的所有RMI调用被顺序化,可能间隔为两分钟,或者可能导致间隔更频繁的任何调用都因BindExceptions失败。

For another, it may have an adverse effect on DGC. 另一方面,它可能会对DGC产生不利影响。

And there is no actual benefit whatsoever. 而且没有任何实际的好处。

Obviously this class is not RMI specific. 显然,此类不是RMI特定的。

What class? 什么级别? And what's obvious about it? 显而易见的是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM