获取远程PC的MAC地址? [英] Get MAC address of remote PC?

查看:387
本文介绍了获取远程PC的MAC地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从PC获取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;
}

此代码查找我运行它的PC的MAC,但我需要获取远程MAC。

This code finds the MAC of the PC I run it on, but I need to get the remote MAC.

推荐答案

你不能用Java做到这一点,如果你做一些研究,你会发现除了以太网层和连接到它的网卡之外,MAC地址并没有太多用处。

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.

这篇关于获取远程PC的MAC地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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