When reading and writing data to a socket, you must write your code to accept reading or writing less data than requested. The
writefunction calls return the number of bytes actually read or written. You can get away with ignoring this value in a lot of situations, but not so with socket programming. The amount of data read or written will frequently be less than what you requested when dealing with sockets, so you must write the code to buffer the data and loop in order to make multiple calls.
Stay up-to-date by subscribing to the Comments RSS Feed for this post.