Question about getting a clients MAC address

Discussion to talk about software related topics only.
Post Reply
dkoste01
Posts: 9
Joined: Thu Apr 12, 2012 8:33 pm

Question about getting a clients MAC address

Post by dkoste01 »

Hello,
I'm using one of the TCP examples to do a small project, but I'm stuck. Basically, I wanted to display the MAC address and the IP address of everyone connected. I did the IP part, but I don't know how to get the MAC address of a connected client. Any help?
User avatar
pbreed
Posts: 1091
Joined: Thu Apr 24, 2008 3:58 pm

Re: Question about getting a clients MAC address

Post by pbreed »

The public interface way if speed is not an issue:

from

#include <arp.h>
/*
******************************************************************************

Get the MAC address from an IP address
This does not send and arp it only checks the arp cache.
If you want it to send an arp then ping the address before calling this function.


Parameters ip address to look up.
mac MACADR structure to hold the result.(C++ pass by reference)

Return:
True if it found a valid arp entry.
False if it did not.

******************************************************************************
*/
BOOL GetArpMacFromIp(IPADDR ip,MACADR & ma);


If speed matter do this once and cache the result.
dkoste01
Posts: 9
Joined: Thu Apr 12, 2012 8:33 pm

Re: Question about getting a clients MAC address

Post by dkoste01 »

Thank you so much, you sir are a life saver.
Post Reply