Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
535 views
in Technique[技术] by (71.8m points)

python - problem with invoking sockets command: winerror 10022

This is my code (for windows 7):

sock=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
address=('224.1.1.1', 1900)
sock.bind(address)
sock.settimeout(0)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)

On the last row I'm getting: winerror 10022

Why do I get it?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

10022 is "Invalid argument". Your socket is not correct for ioctl.

From https://docs.microsoft.com/en-us/windows/win32/winsock/winsock-ioctls :

SIO_RCVALL

Enables a socket to receive all IPv4 or IPv6 packets passing throuigh a network interface. The socket handle passed to the WSAIoctl function must be one of the following:

  • An IPv4 socket that was created with the address family set to AF_INET, the socket type set to SOCK_RAW, and the protocol set to IPPROTO_IP.
  • An IPv6 socket that was created with the address family set to AF_INET6, the socket type set to SOCK_RAW, and the protocol set to IPPROTO_IPV6.

Only members of the Administrators group can create sockets of type SOCK_RAW on Windows 2000 and later.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...