Are BSD/Posix sockets reentrant?

痴心易碎 提交于 2019-12-24 06:23:31

问题


Can several threads operate on the same socket descriptor, i.e accept(sock_fd) at the same time without concern?

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


回答1:


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.



来源:https://stackoverflow.com/questions/2133224/are-bsd-posix-sockets-reentrant

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!