Broken Pipes & Comparison Between send() and sendall() | Sololearn: Learn to code for FREE!


Broken Pipes & Comparison Between send() and sendall()

Hey, 1. I get this error in my program: BrokenPipeError: [Errno 32] Broken pipe How can I fix it? what does it mean? 2. what's the difference between socket.send() and socket.sendall()? Which one should I use? all i know is that sendall() is a higher level pythonic function.

9/20/2021 7:38:35 PM


2 Answers

New Answer


2. All of them send data to the socket. Send returns the number of bytes sent. Sendall continues to send data until all data has been sent and returns None. I can write something like sendall function. Maybe it will be useful. def sendall(sock, data): n = sock.send(data) if n > 0: return sendall(sock, data[n:]) return None In case of most simple network applications you should use sendall.


1. It could mean a socket on client side is closed. Handle the exception.