16

I'm reading Tutorial on Network Programming with Python, and in this document the author is saying that "The function sendall() should be used only with blocking sockets."

But I do not see any such condition in the Python documentation, socket.sendall(string[, flags]).

Is the author of PyNet right?

2 Answers 2

14

When in doubt, check the source.

socket_sendall clearly gives up once send() returns -1, which it will do (with errno of EAGAIN or EWOULDBLOCK) if you call it on a non-blocking socket without calling poll() or select(). (And the internal_select function skips calling poll()/select() when the socket is non-blocking.)

So I would say the PyNet author is correct.

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

1 Comment

doesn't that sounds like a mistake from the developer of that module not to have handled EAGAIN and EWOULDBLOCK ? these can hardly be considered exceptional conditions, imho.
6

sendall() doesn't make sense on non-blocking socket. It has to block if it can't send all data at once, otherwise it wouldn't be called "sendall".

Comments

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.