updated to Stevens' version of sock_fd_read/write()