Get MAC address of remote PC?

给你一囗甜甜゛ 提交于 2019-12-17 14:52:13

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/8046725/get-mac-address-of-remote-pc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!