Socket Win32 IO

Peter Hansen peter at engcorp.com
Mon Jul 7 11:53:53 EDT 2003


jose maria wrote:
> 
> Hi all I´m a newbie in python Im try to modify in win32 IOTCL of file
> handle socket to set parameter 0x98000001 but i have error
> (api_error:(1, 'DeviceIoControl', 'Incorrect function.'))
> and I dont know how continue.
> the porpuse of this code its to make a simple sniffer
> 
> fh=Sock.fileno() # Get file handle
> test=win32file.DeviceIoControl(fh,SIO_RCVALL,'',0) # Failed
> ....
> ....

Is that ("incorrect function") really the error you are getting?
Can you post the actual traceback, if it's not?  

I get either of these when playing with DeviceIoControl, but not
what you showed:

>>> win32file.DeviceIoControl(3, 0x98000001, '', 0)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
pywintypes.api_error: (6, 'DeviceIoControl', 'The handle is invalid.')
>>> from socket import *
>>> s = socket(AF_INET, SOCK_STREAM)
>>> s.fileno()
32
>>> win32file.DeviceIoControl(32, 0x98000001, '', 0)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
pywintypes.api_error: (87, 'DeviceIoControl', 'The parameter is incorrect.')

-Peter




More information about the Python-list mailing list