java进程端口,给定其进程id,是否可以使用java查找进程正在使用的端口?

Is there a way to find a port opened by java process, given the process id of the process in java?

Need to find it using java as it has to be platform independent

Given a process id : output any port/socket connections being used by that process.

Few things given:

Process running in same jvm.

There is only 1 port/socket being used by that Process,

for which the Pid is given.

Can not do platform specific commands like ps -au | grep pid | ...

解决方案

The answer is no. What processes have what ports is not information available to java applications at all. You'd need JNI and it would depend on the operating system.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值