Pathologically Eclectic Rubbish Lister | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Actually, I suspect the issue comes from lack of buffering. Because the output isn't buffered, two packets are sent out. The readline receives one, it doesn't have a newline, so it must wait for another. Lots of system calls. Lots more work. Or maybe the OS starts performing its own buffering when you send lots of short strings, and the delay is the OS making sure you're not about to send another. You can keep your code structure by turning off the buffering on the socket and explicitly flushing the socket when you output a newline. PS — You might benefit from examining the traffic with tcpdump. In reply to Re: Help me understand/fix buffering issue for tcp?
by ikegami
|
|