如何检查客户端是否连接到tcp / ip端口

时间:2022-07-06 07:22:48

I have scenario where there is a application(TCP-com PORT MAPPING SOFTWARE) which act as server and listens on port(2293) and maps to COM1. There is another java application where i have to check whether any client is connected on port no(2293) and if connected do some useful thing. I have to check whether this port(2293) which that software is listening is connected( not whether it is open or accessible).

我有一个应用程序(TCP-com PORT MAPPING SOFTWARE)的场景,它充当服务器并侦听端口(2293)并映射到COM1。还有另一个java应用程序,我必须检查是否有任何客户端连接在端口号(2293)和连接是否做一些有用的事情。我必须检查该软件正在侦听的此端口(2293)是否已连接(无论是打开还是可访问)。

Is there any method to detect this situation.

有没有办法检测这种情况。

Thanks in advance.

提前致谢。

3 个解决方案

#1


0  

If it's a windows based system you should try running "netstat" from your command prompt. That should show all applications with open ports and if these ports are listening for data or not.

如果它是基于Windows的系统,您应该尝试从命令提示符运行“netstat”。这应该显示所有具有开放端口的应用程序以及这些端口是否正在侦听数据。

#2


0  

Windows run cmd

Windows运行cmd

netstat -an |findstr ESTABLISHED |findstr :2293

Linux run

netstat -an |grep ESTABLISHED |grep :2293

#3


0  

That functionality should be in the server. It knows all right. There is no Java API that lets you detect that condition from outside.

该功能应该在服务器中。它知道没事。没有Java API可以让您从外部检测到这种情况。

#1


0  

If it's a windows based system you should try running "netstat" from your command prompt. That should show all applications with open ports and if these ports are listening for data or not.

如果它是基于Windows的系统,您应该尝试从命令提示符运行“netstat”。这应该显示所有具有开放端口的应用程序以及这些端口是否正在侦听数据。

#2


0  

Windows run cmd

Windows运行cmd

netstat -an |findstr ESTABLISHED |findstr :2293

Linux run

netstat -an |grep ESTABLISHED |grep :2293

#3


0  

That functionality should be in the server. It knows all right. There is no Java API that lets you detect that condition from outside.

该功能应该在服务器中。它知道没事。没有Java API可以让您从外部检测到这种情况。