Java RMI和netstat输出 [英] Java RMI and netstat output

查看:86
本文介绍了Java RMI和netstat输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使我的RMI服务跨防火墙运行.我按照此答案中的说明在端口1099上同时运行RMI注册表和我的RMI服务,但是netstat时,在RMI客户端和服务器上打开的端口号.

I'm trying to make my RMI service work across a Firewall. I followed instructions in this answer to run both RMI Registry and my RMI service on port 1099, yet, I'm seeing different port numbers being opened on RMI client and server when I do netstat.

[user@machine] ~ $ netstat -ant | grep 1099
tcp6       0      0 :::1099                 :::*                    LISTEN     
tcp6       0      0 10.1.1.1:1099         10.1.1.2:33400        ESTABLISHED
tcp6       0      0 10.1.1.1:1099         10.1.1.1:33378        ESTABLISHED
tcp6       0      0 10.1.1.1:33408        10.1.1.1:1099         ESTABLISHED
tcp6       0      0 10.1.1.1:1099         10.1.1.1:33408        ESTABLISHED
tcp6       0      0 10.1.1.1:46866        10.1.1.2:1099         ESTABLISHED
tcp6       0      0 10.1.1.1:1099         10.1.1.2:33404        ESTABLISHED
tcp6       0      0 10.1.1.1:33378        10.1.1.1:1099         ESTABLISHED
tcp6       0      0 10.1.1.1:46862        10.1.1.2:1099         ESTABLISHED
tcp6       0      0 10.1.1.1:46864        10.1.1.2:1099         ESTABLISHED
tcp6       0      0 10.1.1.1:1099         10.1.1.2:33402        ESTABLISHED
tcp6       0      0 10.1.1.1:46860        10.1.1.2:1099         ESTABLISHED

10.1.1.1和10.1.1.2都是RMI服务器和客户端互相通信.

10.1.1.1 and 10.1.1.2 are both RMI servers and clients talking to each other.

这是我的代码段:

IRemoteService存根=(IRemoteService) UnicastRemoteObject.exportObject(service,1099);

IRemoteService stub = (IRemoteService) UnicastRemoteObject.exportObject(service, 1099);

registry = LocateRegistry.createRegistry(1099);

registry = LocateRegistry.createRegistry(1099);

registry.rebind(IRemoteService.serviceName,stub);

registry.rebind(IRemoteService.serviceName, stub);

这是预期的吗?为什么我看到端口号为33400、33378等?还是我对源端口和目标端口的工作方式了解不正确?我希望看到所有连接(注册表查找和远程服务调用)仅连接到端口1099.

Is this expected? Why am I seeing port #'s like 33400, 33378 etc? Or is my understanding of how source and destination ports work wrong? I was hoping to see all connections (registry lookup and remote service calls) going to port 1099 only.

注意:我还没有在防火墙环境中运行以上操作,只是在实验室中尝试之前在实验室中进行了本地尝试.

Note: I did not run the above in a Firewall environment yet, just trying locally in my lab before I try in a Firewall situation.

推荐答案

tcp6       0      0 10.1.1.1:1099         10.1.1.2:33400        ESTABLISHED

端口33400上的客户端与端口1099上的服务器之间的连接.您不能仅从此行中得知这一点,而是提到了使用1099的RMI,并且之前会有1099 LISTENING线路.

A connection between a client on port 33400 and a server on port 1099. You can't tell that from this line alone but you mentioned RMI which uses 1099, and there would have been a prior line with 1099 LISTENING.

tcp6       0      0 10.1.1.1:1099         10.1.1.1:33378        ESTABLISHED

端口33378上的客户端与端口1099上的服务器之间的连接.与上述相同.

A connection between a client on port 33378 and a server on port 1099. Same remark as above.

tcp6       0      0 10.1.1.1:33408        10.1.1.1:1099         ESTABLISHED

端口33408上的客户端与端口1099上的服务器之间的连接.与上述相同.如果客户端位于其他主机上,则此行将仅显示在客户端主机上.

A connection between a client on port 33408 and a server on port 1099. Same remark as above. If the client was on a different host, this line would only show at the client host.

tcp6       0      0 10.1.1.1:1099         10.1.1.1:33408        ESTABLISHED

该连接的另一端.此行仅显示在服务器主机上.

The other side of that connection. This line only shows at the server host.

tcp6       0      0 10.1.1.1:46866        10.1.1.2:1099         ESTABLISHED
tcp6       0      0 10.1.1.1:1099         10.1.1.2:33404        ESTABLISHED
tcp6       0      0 10.1.1.1:33378        10.1.1.1:1099         ESTABLISHED
tcp6       0      0 10.1.1.1:46862        10.1.1.2:1099         ESTABLISHED
tcp6       0      0 10.1.1.1:46864        10.1.1.2:1099         ESTABLISHED
tcp6       0      0 10.1.1.1:1099         10.1.1.2:33402        ESTABLISHED
tcp6       0      0 10.1.1.1:46860        10.1.1.2:1099         ESTABLISHED

等等.

这是预期的吗?

Is this expected?

是的

为什么我看到端口号为33400、33378等?

Why am I seeing port #'s like 33400, 33378 etc?

因为连接有两个端点:服务器端和客户端,并且通常是相当随机地选择客户端端口.

Because connections have two ends: a server end and a client end, and the client port is normally chosen fairly randomly.

还是我对源端口和目标端口的工作方式了解不正确?我希望看到所有连接(注册表查找和远程服务调用)仅连接到端口1099.

Or is my understanding of how source and destination ports work wrong? I was hoping to see all connections (registry lookup and remote service calls) going to port 1099 only.

是的.但是这些连接有客户端.

They are. But there are client ends to those connections.

这实际上是关于TCP和netstat的问题,而不是有关RMI或Java的问题.

This is really a question about TCP and netstat, not RMI or Java.

这篇关于Java RMI和netstat输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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