A common socket programming mistake: not handling short IO
April 8, 2006
With normal file IO, when you do do '
This can and will bite you on the rear when writing socket code, because networks only give you so much data at once. Short reads are routine for socket IO; you can't assume that you can get all of what you want in a single read.
The mistake is especially pernicious because the mistaken code almost always works. Usually the lines or transactions you're reading from the network are small; usually you test on a fast local network. Speaking from personal experience, it's easy to forget this and then not notice.
(Today's case was some of my code that assumed it could read all of
Whether or not a normal (blocking)
* * *
Atom feeds are available; see the bottom of most pages.