如何使用 Java 代码找出访问我的 Ubuntu 计算机的 WLAN 接口的 PC 的 IP 地址?
我想一次限制资源访问仅限 1 个客户端。
如果第二个唯一客户端尝试访问我的电脑(充当服务器),则不应允许它,直到前一个客户端完成其工作(或在指定时间内)。
通过跟踪访问我的资源的 IP 地址,我想阻止/取消阻止客户端访问或传输数据。
有没有办法开发一个 Java 应用程序来调用 Linux 网络 API 来获取这些事件的详细信息,包括客户端的 IP 地址?
I would like to limit resource access to only 1 client at a time.
If a 2nd unique client tries to access my PC (which is acting as a server) then it should not be allowed, until the previous client is done with its work (or for a specified time).
By tracking IP addresses that are accessing my resource, I would like to block/unblock clients from accessing or transferring data.
Is there any way to develop a Java application that will call the Linux networking APIs in order to get details of these events, including the IP address of the client?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过命令行,您可以使用
netstat -unt
查看远程 IP 正在访问您的每个接口。但是,对于您的应用程序,您最好在共享数据库中维护已连接客户端的列表。请务必跟踪连接的建立时间或上次传输的数据,以便使过时的数据过期。Via a command line, you can see remote IP's accessing each of your interfaces using
netstat -unt
. However, for your application, you are probably better off maintaining a list of connected clients in a shared database. Be sure to track when the connection was made or last transmitted data so you can expire stale data.