314314314
314314314

Reputation: 259

Why NetworkInterface's methods throw SocketException

For example - public byte[] getHardwareAddress() throws SocketException. The method returns the mac address of a network interface, but how is it related to sockets and ends up throwing SocketException?

Upvotes: 2

Views: 157

Answers (1)

apangin
apangin

Reputation: 98620

On Linux getHardwareAddress() is implemented using SIOCGIFHWADDR ioctl request on a temporarily created datagram socket. Something like this.

Both socket and ioctl system calls may fail. The error will be translated to SocketException.

Upvotes: 2

Related Questions