From: Stephen S. <rad...@gm...> - 2016-05-11 21:00:54
|
On Wed, May 11, 2016 at 5:49 PM, Erik Ronström <eri...@do...> wrote: >>> Assuming that send(), write() and the like complete the requested >>> number of bytes is a pretty serious bug. >> >> For send(), if there is an error on sending, the socket is closed. In no case does it assume a send >> worked when it didn’t. > > Well, it depends on how you look at it. A partial send could certainly be regarded as a failure in this context. Indeed, the consequences of a partial send is probably worse than of a completely failed send, because in the latter case, the client code could just retry sending the message. The receiver has no way to know how to abort the message and wait for the next one unless the number of bytes specified has been sent. The options in case of a partial send are (1) memorize the unsent message and try to complete it next time -- would require changes to the liblo API (2) pad the message with zeros or something (likely a bad solution, since the receiver has no way to know that it received a bad message, not even a parity check, so the zeros could be interpreted as valid message data.) (3) close the stream The framing protocol doesn't allow for anything else, as far as I can think of. Solutions (1) and (2) gets worse if you consider that the message length might have been interrupted, so the client might mistake how many bytes the receiver is waiting for. The only legal and reliable way I can think of to indicate a reset, if the message can't be completed, is to close the socket. So liblo checks for an error return from send() and closes the socket in that case. What you discovered is that an inundated receiving socket and produce send() errors. (I think.) However, in a sense this is probably the right thing to do, as it is similar to a DDoS attack, so dropping the connection is probably fine. You should organize your system to not overload the server. The SLIP protocol does allow recovery, since the packet can be ended before all bytes were received and a new one started. Steve |