Situation:
I have a sendersocket which is bound to localhost UDP port 33100. I have a receiversocket socket bound to localhost UDP port 33101.
The sender socket sends 4500 bytes of data (the string "hello man" * 500). On the receiver side, I have an epoll object which waits for the EPOLLIN event on the receiversocket. When there's an event, I do:
while True:
msg_received = receiver_socket.recv(128)
if msg_received.decode("UTF-8") == "":
break
else:
print msg_received.decode("UTF-8")
Problem:
The main problem is that I cannot read again after I have read the first 128 bytes of data. The sender side says it sent 4500 bytes of data as expected.
If the sender sends the same 4500 bytes of data again, the EPOLLIN event is registered again and I read the new string. Somehow, the buffer get's cleared after my first read.
Now even though the sender just sent me 4500 bytes of data, the first recv
gives me 128 bytes of data and then nothing is recv
ed after that.
I am probably doing something really stupid so please enlighten me. I want to receive all the 4500 bytes of data.