Skip to the content ForoHackers
Log inJoin

Why did my reading program eat exactly half a sentence and act full?

Network protocolsPythonTesting
#8729 · · Quote · Report

Local toy only. First byte says five, followed by HELLO. I feed it in two chunks, the first one has just HE after the count. My code gives me HE, then treats the next L as the length of a new message. Lunch is now seventy-six bytes long. Who approved this sandwich?

#8840 · · Quote · Report

A read can give you up to what you requested. It hasn't promised the writer's chunk boundaries, let alone yours. Keep the expected length and the partial body; don't consume a new length byte until the current five bytes are accounted for.

#8841 · · Quote · Report

Tried feeding one byte at a time. That found a second bug: if input ends after HELL my version used to serve it anyway. Now it reports a short message. There is definitely a joke in the missing O but it is five in the morning here.

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply