trying to use SOCK_RAW yields error "

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tzury Bar Yochay

    trying to use SOCK_RAW yields error "

    I am trying to create raw socket:

    server = socket.socket(s ocket.AF_INET, socket.SOCK_RAW ,
    socket.getproto byname('ip'))

    As a result I get the following error:

    Traceback (most recent call last):
    File "tcpsrv.py" , line 14, in <module>
    server = socket.socket(s ocket.AF_INET, socket.SOCK_RAW ,
    socket.getproto byname('ip'))
    File "/usr/lib/python2.5/socket.py", line 154, in __init__
    _sock = _realsocket(fam ily, type, proto)
    socket.error: (93, 'Protocol not supported')


    Does anybody have used socket.SOCK_RAW in the past?
  • Wojtek Walczak

    #2
    Re: trying to use SOCK_RAW yields error &quot;

    Dnia Tue, 12 Aug 2008 05:40:36 -0700 (PDT), Tzury Bar Yochay napisa³(a):

    Hi,
    server = socket.socket(s ocket.AF_INET, socket.SOCK_RAW ,
    socket.getproto byname('ip'))
    ....
    Does anybody have used socket.SOCK_RAW in the past?
    When using SOCK_RAW, the family should be AF_PACKET,
    not AF_INET. Note that you need root privileges to do so.

    --
    Regards,
    Wojtek Walczak,

    Comment

    • Tzury Bar Yochay

      #3
      Re: trying to use SOCK_RAW yields error &quot;

      When using SOCK_RAW, the family should be AF_PACKET,
      not AF_INET. Note that you need root privileges to do so.
      I changed as instructed:
      server = socket.socket(s ocket.AF_PACKET , socket.SOCK_RAW ,
      socket.getproto byname('ip'))

      now I am getting:

      Traceback (most recent call last):
      File "tcpsrv.py" , line 15, in <module>
      server.bind((ho st,port))
      File "<string>", line 1, in bind
      socket.error: (19, 'No such device')

      Comment

      • Wojtek Walczak

        #4
        Re: trying to use SOCK_RAW yields error &quot;

        Dnia Tue, 12 Aug 2008 07:21:15 -0700 (PDT), Tzury Bar Yochay napisa³(a):
        I changed as instructed:
        server = socket.socket(s ocket.AF_PACKET , socket.SOCK_RAW ,
        socket.getproto byname('ip'))
        >
        now I am getting:
        >
        Traceback (most recent call last):
        File "tcpsrv.py" , line 15, in <module>
        server.bind((ho st,port))
        File "<string>", line 1, in bind
        socket.error: (19, 'No such device')
        What's the value of host variable? AFAIR it should be the name
        of the interface you want to bind to ('eth0', 'ppp0', whatever).


        --
        Regards,
        Wojtek Walczak,

        Comment

        Working...