test SO_RCVTIMEO and MSG_WAITALL
1.首先两者都运用于阻塞的情景下,对nonblock的fd不起作用。
2.SO_RCVTIMEO, socket选项,作为getsockopt, setsockopt的参数。见下 figure1.
SO_RCVTIMEO选项可以指定阻塞调用的超时时长,SO_RCVTIMEO的影响的函数read, readv, recv, recvfrom, recvmsg.
3.MSG_WAITALL, recv调用的参数,
MSG_WAITALL
On SOCK_STREAM sockets this requests that the function block
until the full amount of data can be returned. The function may
return the smaller amount of data if the socket is a message-
based socket, if a signal is caught, if the connection is termi‐
nated, if MSG_PEEK was specified, or if an error is pending for
the socket.
ps:
recv(sockfd, buff, buff_size, MSG_WAITALL),
在正常情况下recv 是会等待直到读取到buff_size 长度的数据,但是这里的WAITALL 也只是尽量读全,在有中断的情况下recv 还是可能会被打断&