socket.AF_INET
Juergen Perlinger
juergen.perlinger at t-online.de
Sun Apr 20 15:45:02 EDT 2008
Matt Herzog wrote:
> Hi All.
>
> I'm trying to write a script that will send me an email message when my IP
> address changes on a specific NIC. On Linux, the script works. On FreeBSD,
> it fails with:
>
> [snip]
>
> def get_ip_address(ifname):
> s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
> return socket.inet_ntoa(fcntl.ioctl(
> s.fileno(),
> 0x8915, # SIOCGIFADDR
> struct.pack('256s', ifname[:15]) )[20:24])
>
[OT: sorry Matt, hit email instead followup twice... stupid me]
My bets are that the SIOCGIFADDR opcode has a different numerical value for
BSD. Even if some names are portable, the numerical values aren't! I don't
have BSD, but using
find /usr/include -type f -name '*.h' | xargs grep SIOCGIFADDR /dev/null
should give some hints...
--
juergen 'pearly' perlinger
"It's hard to make new errors!"
More information about the Python-list
mailing list