获取远程PC的MAC地址?
我需要从 PC 获取 MAC 地址。到目前为止我写的代码在这里(这只是代码的一小部分)。
public byte[] getMac(L2PcInstance player)
{
try
{
NetworkInterface ni = NetworkInterface.getByInetAddress(player.getClient().getConnectionAddress());
if (ni != null)
{
byte[] mac = ni.getHardwareAddress();
if (mac != null)
{
return mac;
}
}
}
catch (SocketException e)
{
_log.log(Level.SEVERE, "No MAC address.", e);
}
return null;
}
此代码查找我运行它的 PC 的 MAC,但我需要获取远程 MAC。
I need to get the MAC address from a PC. The code I've written so far is here (this is only a small part of the code).
public byte[] getMac(L2PcInstance player)
{
try
{
NetworkInterface ni = NetworkInterface.getByInetAddress(player.getClient().getConnectionAddress());
if (ni != null)
{
byte[] mac = ni.getHardwareAddress();
if (mac != null)
{
return mac;
}
}
}
catch (SocketException e)
{
_log.log(Level.SEVERE, "No MAC address.", e);
}
return null;
}
This code finds the MAC of the PC I run it on, but I need to get the remote MAC.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Java 中你无法做到这一点,如果你做一些研究,你会发现 MAC 地址除了以太网层和连接到它的 NIC 之外并没有多大用处。
You can't do that in Java, and if you do some research you will find that the MAC address isn't really much use to anything except the Ethernet layer and the NICs attached to it.