Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果接受系统调用返回错误,预期的错误处理是什么?我们应该关闭套接字吗?
这取决于错误。成功时,accept()返回新连接的套接字(文件描述符)。如果失败,您不需要关闭尚未收到的套接字(像许多系统调用一样,accept()返回 -1 表示错误)。
accept()
但是,根据错误代码,您可能决定关闭侦听套接字。