不,套接字不会从侦听套接字继承非阻塞状态。你必须自己让它不阻塞。
来自man 2 accept:
int accept4(int sockfd, struct sockaddr *addr,
socklen_t *addrlen, int flags);
Run Code Online (Sandbox Code Playgroud)
进一步向下:
If flags is 0, then accept4() is the same as accept(). The following
values can be bitwise ORed in flags to obtain different behavior:
SOCK_NONBLOCK Set the O_NONBLOCK file status flag on the new open
file description. Using this flag saves extra calls to
fcntl(2) to achieve the same result.
Run Code Online (Sandbox Code Playgroud)
因此,我希望从accept()返回的套接字描述符处于阻塞模式.