javacnetwork-programmingprivate-network

Can we connect to a computer on the same private network using MAC address?


I could connect two computers withing a private network using private IP addresses using socket programming. Is it possible to do the same using MAC addresses?

If it is possible, any example on Java/C/C++ would be appreciated. I couldn't find any helpful posts on the web regarding the same.

UPDATE:

I was curios to know if it's possible to connect to another computer on the same private network just by knowing the MAC address? One logic behind the question could be the IP address assigned to a network device can be different everytime the router is rebooted. So, MAC address sounds more solid option to have for identity in this case.

(Though I am aware MAC address can be changed too.)


Solution

  • MAC addresses are used to identify "physical" entities in a network.

    Whereas sockets exist on the IP layer.

    MAC addresses denote hardware objects; if you want those objects to communicate, you need to look into the layers above of that. And either you use existing protocols; such as UDP/TCP; or you would have to define your complete own protocol.

    In other words: the one and only function of a MAC address is to identify a unique hardware component within the "scope" of the visible network. The MAC address doesn't define any service/protocol that could be used to connect one MAC address endpoint to another one.

    So, in short the answer is: no it is not passable.