Problem w/networking code...
Micheal Kelly
michealk at newlix.com
Fri Aug 11 11:43:47 EDT 2000
Hi all,
I'm trying to obtain some network configuration information using
ioctl() and Python under Linux. From what I've been told, I can
bind a socket, then use ioctl to query various stats, such as
IP address, broadcast, netmask, etc...
The example below should (from what I understand) return the IP
address the socket is bound to (which I already know, since I bound
it there in the first place - this is just a test, not very useful. :)
I end up with the following error:
Traceback (innermost last):
File "./test.py", line 11, in ?
fcntl.ioctl(s.fileno(), IOCTL.SIOCGIFADDR)
IOError: [Errno 14] Bad address
Any thoughts?
------------
#!/usr/bin/python
from socket import *
import fcntl, FCNTL, IOCTL
HOST = '192.168.3.52'
PORT = 50007
s = socket(AF_INET, SOCK_STREAM)
s.bind(HOST, PORT)
test = fcntl.ioctl(s.fileno(), IOCTL.SIOCGIFADDR)
print test
More information about the Python-list
mailing list