If server and client are on the same network, you will have to use ARP. This protocol is designed to get the MAC address to a given IP address.
As soon as there is something like a router between client and server, ARP will only reveal the MAC address of the router since this is the target for your ethernet packets.
solved How could I convert from IP address to MAC address