vmiklos/bitlbee — pull request #5 by mk-fg (2013-02-07 07:18:43+00:00)
Title: skype: add newline to all the lines emitted

Not sure if that needs to be said, but I'm pretty sure when using stream bsd sockets, doing "read(1024)" on the other end might get you (buffered at any point in the network/os-stacks) 1024 bytes with incomplete line at the tail and with no delimeters of any kind with regards to how they've been sent out.

With Nagle's send('a') + send('b') is equivalent to send('ab') ('ab' will be sent in a single tcp packet in both cases), so delimiters are absolutely critical - one'd have no idea if full message was received otherwise or it's just a part of it.

Current skyped should strip newlines anyway, and I think the fact that it works fine like that in low-latency environment (so that socket buffers have only one message for each read()) is a bit of an accident.

Guess there's some trick in blocking sockets to allow such behavior that I'm unaware of (with other option stated above), but I think allowing to not rely on such is a good thing, as it allows using non-blocking sockets with e.g. glib loop instead of potentially hanging the loop forever on any recv/send operation (buffer full, other side died w/o sending anything, etc), hence the patch.