]> git.gir.st - ircpipe.git/commit
improve PONG sending
authorTobias Girstmair <t@thi3nkpad.localdomain>
Mon, 20 May 2024 16:04:18 +0000 (18:04 +0200)
committerTobias Girstmair <t@thi3nkpad.localdomain>
Mon, 20 May 2024 16:04:18 +0000 (18:04 +0200)
commit3e11ddccf9cbab111535476ff1ac7d100404da0b
tree5805df67fc8a9881cf27311f3ec30ca1342ec9da
parentb8b988b19e83c3b7350f298d5ef73bc87a9efc20
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