The example is the third example in (Python2.7's doc)->(Python Library 
Reference)->17.2.2.
The code of the example is:

import socket

# the public network interface
HOST = socket.gethostbyname(socket.gethostname())

# create a raw socket and bind it to the public interface
s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP)
s.bind((HOST, 0))

# Include IP headers
s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)

# receive all packages
s.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)

# receive a package
print s.recvfrom(65565)

# disabled promiscuous mode
s.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)


However, when I run it, the interpreter show the following error:

Traceback (most recent call last):
  File "E:\c language\Eclipse\example\src\sniffer.py", line 12, in <module>
    s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP)
  File "D:\Python27\lib\socket.py", line 187, in __init__
    _sock = _realsocket(family, type, proto)
socket.error: [Errno 10013] 

What's the matter?




daedae11
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to