I'm writing a basic socket program in Python3, which consists of three different programs - sender.py, channel.py, and receiver.py. The sender should send a packet through the channel to the receiver, then receiver sends an acknowledgement packet back.
It works for sending one packet - it goes through the channel to the receiver, and the receiver sends an acknowledgement packet through the channel to the sender, which gets it successfully. But when the sender tries to send a second packet, it attempts to send it but gets no response, so it sends it again. When it does, it gets BrokenPipeError: [Errno 32] Broken pipe. The channel gives no indication that it receives the second packet, and just sits there waiting. What does this mean and how can it be avoided?
I never call close() on any of the sockets.
It was because I was generating a new socket each time, rather than just re-using one socket.
How do I avoid a BrokenPipeError while using the sockets module in Python?