On Thu, Jan 16, 2020 at 09:35:38AM +0000, [email protected] wrote: > Raymond, David writes: > > I am confused about SSIZE_MAX and read(2)/write(2). The POSIX > > SSIZE_MAX is something like 2^15 -1. This seems to be a real > > limitation when writing to a TCP/IP socket, as I learned from > > experience. However, much larger reads and writes seem to be possible > > to files and UNIX sockets (pipes). This makes me uneasy, given the > > warning in the man pages for read(2)/write(2). > > > > Any insight on this topic would be appreciated. > > I would guess this is part of the reason why ssize_t was invented > - so that half of the numeric range could be wasted in order for a > function to be able to return -1, and/or ridiculous notions of > symmetry.
Most people out there don't understand C numeric types, as a very long list of signed vs unsigned bugs in all kinds of tools show. Clamping down to a value that has less chance of confusing the numerous idiots out there seems like a valid approach to me.

