Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 841
Cuero Avatar asked Mar 31 '16 06:03

Cuero


1 Answers

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

like image 197
Efi Weiss Avatar answered Sep 22 '22 07:09

Efi Weiss