2

I'm trying to create a simple echo server that can handle multiple connections, I am using select and need to use non blocking sockets but I get an error saying 'BlockingIOError: [Errno 35] Resource temporarily unavailable' on the line where I receive the data.

Here's the server and client code

inputs = [server]

while True:
    inready, outready, excready = select.select(inputs, [], [])

    for s in inready:
        if s == server:
            client, address = server.accept()
            client.setblocking(0)
            print(address)
            inready.append(client)

        else:
            data = s.recv(1024);
            if data:
                s.send(data)
            else:
                inputs.remove(s)
                s.close()

1 Answer 1

1

This little error took me also a while to find:

            inready.append(client)

Correct is, of course:

            inputs.append(client)

Since inready was accidentally modified, the else block was executed when it shouldn't have been.

Sign up to request clarification or add additional context in comments.

1 Comment

This is life saver! I had the same problem lol! I smash that thumb up button!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.