I’m trying to use ‘non-blocked socket’ for a Python project
(see previous question if anyone has a better answer : How to use a socket without waiting in python )
I saw that people on the site suggested using the command:
socket.setblocking ()
But when I run the program it crashes, and the error is recorded:
AttributeError: module 'socket' has no attribute 'setblocking'
How can I fix this?
And is there another way?
Advertisement
Answer
It looks like you are trying to call setblocking()
on the module called socket
rather than on the object called socket
.
Change your code to something like:
import socket s = socket.socket(...) s.setblocking(...)