什么时候bind()上的错误会发生?

时间:2013-08-07 10:36:01

标签: c linux bind

man bind

中获取的错误
    ENOTSOCK // sockfd is a descriptor for a file, not a socket. The following errors are specific to UNIX domain (AF_UNIX) sockets:
    EFAULT // addr points outside the user's accessible address space.
    ELOOP // Too many symbolic links were encountered in resolving addr.
    ENOENT // The file does not exist.
    ENOTDIR // A component of the path prefix is not a directory.
    EROFS// The socket inode would reside on a read-only file system.

尤其是当ELOOP,ENOENT,ENOTDIR,EROFS发生时我无法理解。这是否与某些特殊文件系统有关,如nfs等等?

1 个答案:

答案 0 :(得分:4)

请记住,套接字和bind不仅可用于网络通信。请参阅示例Unix domain sockets,它们被绑定为文件系统中的文件。

它甚至出现在你自己引用的错误列表中:

  

以下错误特定于UNIX域(AF_UNIX)套接字