Socket Win32 IO

jose maria scasjos at mixmail.com
Tue Jul 8 14:39:46 CEST 2003


Peter Hansen <peter at engcorp.com> wrote in message news:<3F099791.6AA68B8F at engcorp.com>...
> 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

Hello Peter tanks for you attenion and time 

Yes really I forget put in the message one parameter in the function 
I put the traceback and all code I hope that this help you. Thousands
of pardons for my bad English

Traceback:

ActivePython 2.2.1 Build 222 (ActiveState Corp.) based on
Python 2.2.1 (#34, Apr 15 2002, 09:51:39) [MSC 32 bit (Intel)] on wi
Type "help", "copyright", "credits" or "license" for more informatio
>>> from socket import *
>>> import win32api
>>> import win32file
>>> Ip=getprotobyname("ip")
>>> SIO_RCVALL=0x98000001
>>> ip=('xxx.xxx.xxx.xxx',0)
>>> Sock=socket(AF_INET,SOCK_RAW,Ip) #Raw Socket 
>>> Sock.bind(ip) # Bind Socket to ip 
>>> fh=Sock.fileno() # Get file handle
>>> test=win32file.DeviceIoControl(fh,SIO_RCVALL,"", 0,None) # The
function
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
pywintypes.api_error: (1, 'DeviceIoControl', 'Incorrect function.')

EndTraceBack:




More information about the Python-list mailing list