1

Python 2.7 を使用しています。すべて試しましたが、つながりません。私が得るエラーは次のとおりです。

Socket could not be created. Error Code : 10013 Message An attempt was 
    made to access a socket in a way forbidden by its access permissions.

ピングを行っています。

def doOnePing(destAddr, timeout):
    icmp = socket.getprotobyname("icmp")
    # SOCK_RAW is a powerful socket type. For more details see: 
    # http://sock-raw.org/papers/sock_raw
    # Fill in start
    # Create Socket here
    try:
        #mySocket = socket.socket(2, 3, 1)
        # the public network interface
        HOST = socket.gethostbyname(socket.gethostname())

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

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

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

        # receive a package
        print mySocket.recvfrom(65565)

        print ('Connected by', destAddr)
    except socket.error , msg:
        print ('Socket could not be created. Error Code : ' + str(msg[0]) + 
              ' Message ' + msg[1])
    #Fill in end
4

1 に答える 1

1

特権ユーザーとしてスクリプトを実行してみてください。Linuxのrootユーザーが適切です。

于 2013-10-05T18:13:30.440 に答える