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

0

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

Yahel

2 Answers

New Answer

0

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.

0

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