socket.error: [Errno 102] Operation not supported on socket

12,781

You are using a udp socket, SOCK_DGRAM, and udp does not listen for connections, it receives each message on its own Use recvfrom to receive udp messages

Share:
12,781
Cuero
Author by

Cuero

graduate of Tsinghua University

Updated on June 24, 2022

Comments

  • Cuero
    Cuero about 2 years

    I'm using Python on Mac.

    But the below code

    import socket
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.bind(('127.0.0.1', 443))
    s.listen(2048)
    

    encounters the problem

    Traceback (most recent call last):
      File "attacker.py", line 5, in <module>
        s.listen(2048)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 228, in meth
        return getattr(self._sock,name)(*args)
    socket.error: [Errno 102] Operation not supported on socket
    

    How to resolve this issue?