> I've created a TWSocketServer that spawns a TWSocket per client connection
> (as per the ICS examples). I was wondering if it's possible to obtain the
> MAC address of the connecting client using the HSocket or TWSocket.
> Clients
> will be connecting from remote networks via Internet into my server. I'm
> using ICS v6 on C++ Builder 2009.
>
you'll get their Mac Adress only if the clients are on the same network
Eric
function RENVMAC(adresseIP:string):string;
//always returns a macadress in uppercase xx.xx.xx.xx.xx.xx
//returns '00.00.00.00.00.01' if local IP
//returns '00.00.00.00.00.00' if outside your network
var monip:ulong;
monmac:array[0..5] of byte;
monmaclength:ulong;
MacAdresse:string;
begin
if adresseIP='127.0.0.1' then MacAdresse:='00.00.00.00.00.01' else
begin
MacAdresse:='';
if adresseIP<>'' then
begin
try
monip:=inet_addr(PChar(adresseIP));// uses Winsock
monmaclength:=length(monmac);
//sendarp returns 0 if ok
if sendarp(monip,0,@monmac,@monmaclength)=0 then
begin
MacAdresse:=AnsiUpperCase(format('%2.2x.%2.2x.%2.2x.%2.2x.%2.2x.%2.2x',[monmac[0],monmac[1],monmac[2],monmac[3],monmac[4],monmac[5]]));
end;
except
end;
if length(MacAdresse)<>17 then MacAdresse:='';
end;
end;
if MacAdresse='' then MacAdresse:='00.00.00.00.00.00';
result:=MacAdresse;
end;
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be