ns_read_from_socket(): calling recv() in a loop until failure