]> git.gir.st - ircpipe.git/commit
improve PONG sending
authorTobias Girstmair <tobi@isticktoit.net>
Mon, 20 May 2024 16:04:18 +0000 (18:04 +0200)
committerTobias Girstmair <tobi@isticktoit.net>
Mon, 20 May 2024 16:04:18 +0000 (18:04 +0200)
commite3b6a2c0f5e34af51850c46b6773c0887fa43d7a
tree5805df67fc8a9881cf27311f3ec30ca1342ec9da
parent21b97fb4664f601446c40005eca109bf0bb3e29e
improve PONG sending

this gets rid of the double-send(2) (which in theory allows us to enable
Nagle's TCP_NODELAY). we need to restore the line terminator that strtok
removed. while the spec says we should send \r\n, it would probably
suffice to non-compliantly just do line[n] = '\n' (and rely on postel's
law to save us). but strtok only overwrites the first delimeter;
transforming "...\n..." into "...\0..." and "...\r\n..." into
"...\0\n...". so by looking ahead one byte we can determine which
terminator(s) were sent by the server and send back the same one(s). of
course, this doesn't hold for \n\r, just \r or \n\n (neither of which we
expect), but it would fall back to a sensible form regardless.
ircpipe.c
Imprint / Impressum