使用Java查找无线网络的SSID [英] Finding SSID of a wireless network with Java

查看:168
本文介绍了使用Java查找无线网络的SSID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在做一个用Java编写的项目(为JRE 1.6编译)并需要一些帮助
a很少但显然很复杂的功能:
我们想要在特定的无线网络时采取某种行动连接的当连接的SSID ==myNetworkAtHome或类似的时候。

We're doing a project coded in Java (compiled for JRE 1.6) and need some help with a little but apparently complicated feature: We want to do a certain action when a specific wireless network is connected e.g. when the connected SSID=="myNetworkAtHome" or similar.

在浏览这个网站之后,谷歌和Java文档我们已经接近了。
查看此处的代码后:
http: //download.oracle.com/javase/tutorial/networking/nifs/retrieving.html

After looking through this site, google and the Java documentation we have come a little closer. After looking at the code here: http://download.oracle.com/javase/tutorial/networking/nifs/retrieving.html

看来我们已经接近了但它遇到了一个负面因素,所有接口似乎都连接到net0到net13(在我的笔记本电脑上)。
我们无法从任何接口中获取SSID。我确实意识到示例中的代码仅提供接口名称而不是连接的网络,但它似乎没有提供获取连接的网络信息的方法。

It seems we were getting close but it hits a deadend, all the interfaces seems to be connected to "net0" through "net13" (on my laptop that is.) And we're unable to get the SSID out of any interface at all. I do realise the code in the example is only giving the interface names and not connected networks, but it doesn't seem to offer a way of fetching the connected network information.

任何有关这方面的帮助都非常有帮助!

Any help on this would be extremely helpfull!

问候
Martin NJ

Regards Martin NJ

推荐答案

您无法在Java中访问网络的这种低级细节。您可以使用 NetworkInterface 类获取网络接口的一些详细信息,但是如果您看到提供的方法,则没有人与Wifi网络相关,也无法获得SSID的任何方式提供。如下所述,您应该通过使用JNI调用本机库或使用 Runtime 调用操作系统工具来使用某些本机功能。

You can't access this low-level details of the network in Java. You can get some details of the network interface with the NetworkInterface class but if you see at the provided methods, no one is related to Wifi networks nor any way to get the SSID is provided. As pointed below, you should use some native functionality through calling a native library with JNI or by calling a OS tool with Runtime.

Java不是为了做那种事情而设计的,难以以独立于平台的方式实现,并且原则上无法用Java管理任何硬件级细节。

Java is not designed to do that kind of things, is hard to implement in a platform-independent way and any hardware-level detail can not be managed in Java by principle.

同样适用于3G,GPRS等其他网络......应用程序不应该知道连接类型及其细节。 Java只能管理传输(TCP)级别的东西,而不能管理网络(IP)而不是链接(3G,Wifi,以太网......),所以你只能管理套接字。

Same applies to other networks like 3G, GPRS... the application should not be aware of the connection type nor its details. Java can only manage things at the Transport (TCP) level, not the network (IP) not Link (3G, Wifi, Ethernet...), so you can only manage sockets.

这篇关于使用Java查找无线网络的SSID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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