Re: Socket Win32 IO

Discussion in 'Python' started by Peter Hansen, Jul 7, 2003.

  1. Peter Hansen

    Peter Hansen Guest

    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
    Peter Hansen, Jul 7, 2003
    #1
    1. Advertising

  2. Peter Hansen

    jose maria Guest

    Peter Hansen <> wrote in message news:<>...
    > 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:
    jose maria, Jul 8, 2003
    #2
    1. Advertising

  3. Peter Hansen

    Peter Hansen Guest

    jose maria wrote:
    >
    > 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.')


    I still get a different result (the second of the two that I posted
    before) even if I add that "None" argument, not what you show above.
    Are you certain you are cutting and pasting *exactly* what you typed?
    I note you have 'xxx.xxx.xxx.xxx' above, so presumably you have
    edited the transcript manually in at least one way... any others?

    I'm not likely to be able to solve the problem, since I have no idea
    what DeviceIoControl is for, nor what you're trying to accomplish.
    I just thought I'd report that I do not get the results you are
    getting when I try what you show you are trying.

    -Peter
    Peter Hansen, Jul 8, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laszlo Nagy
    Replies:
    1
    Views:
    4,755
    Mark Wooding
    Jan 27, 2009
  2. Jean-Paul Calderone
    Replies:
    0
    Views:
    942
    Jean-Paul Calderone
    Jan 27, 2009
  3. Laszlo Nagy
    Replies:
    0
    Views:
    524
    Laszlo Nagy
    Feb 1, 2009
  4. Steve Holden
    Replies:
    0
    Views:
    643
    Steve Holden
    Feb 1, 2009
  5. Steve Holden
    Replies:
    1
    Views:
    698
Loading...

Share This Page