r24629: Make read_sock return the total number of bytes read instead