开发者

Are BSD/Posix sockets reentrant?

开发者 https://www.devze.com 2022-12-18 05:20 出处:网络
Can several threads operate on the same socket descriptor, i.e ac开发者_如何学运维cept(sock_fd) at the same time without concern?

Can several threads operate on the same socket descriptor, i.e ac开发者_如何学运维cept(sock_fd) at the same time without concern?

The platform I'm mostly interested in is POSIX/Linux.


Yes, they are "reentrant" - kernel locks the socket structure while working on it (see Linux accept source for example), so only one thread would get the client connection.

0

精彩评论

暂无评论...
验证码 换一张
取 消