📄 bind.2
字号:
.\" SCCSID: @(#)bind.2 8.1 9/11/90.TH bind 2.SH Namebind \- bind a name to a socket.SH Syntax.nf.ft B#include <sys/types.h>#include <sys/socket.h>.PP.ft Bbind(s, name, namelen)int s;struct sockaddr *name;int namelen;.PP.ft B#include <sys/types.h>#include <sys/socket.h>#include <sys/un.h>.PP.ft Bbind(s, name, namelen)int s;struct sockaddr_un *name; int namelen;.fi.SH Description.NXR "bind system call" .NXA "bind system call" "listen system call".NXR "socket" "binding to a name"The.PN bindsystem call assigns a name to an unnamed socket.When a socket is created with the .PN socket call, it exists in a name space (address family)but has no name assigned.The.PN bindsystem call requests that.IR name be assigned to the socket..PPBinding a name in the UNIX domain creates a socket in the filesystem that must be deleted by the caller when it is no longerneeded, using the .PN unlink system call..PPThe.I sockaddrargument specifies a general address family.The.I sockaddr_unargument specifies an address family in the UNIX domain..PPThe rules used in name binding vary between communication domains.Consult the reference pages in the\fIULTRIX Reference Pages Section 4: Special Files\fP for detailed information..SH Return Value If the .PN bindis successful, the call returns a 0 value. A return value of \-1 indicates an error, which isfurther specified in the global variable \fIerrno\fP..SH DiagnosticsThe .PN bindcall fails under the following conditions:.TP 15[EBADF]\fIS\fP is an invalid descriptor..TP 15[ENOTSOCK]\fIS\fP is not a socket..TP 15[EADDRNOTAVAIL]The specified address is not available from the local machine..TP 15[EADDRINUSE]The specified address is already in use..TP 15[EINVAL]The socket is already bound to an address..TP 15[EACCESS]The requested address is protected, and the current userhas inadequate permission to access it..TP 15[EFAULT]The \fIname\fP parameter is not in a valid part of the useraddress space..PPThe following errors are specific to binding names in theUNIX domain:.TP 15[ENOTDIR]A component of the path prefix is not a directory..TP 15[ENAMETOOLONG]A component of a pathname exceeds 255 characters,or an entire pathname exceeds 1023 characters..TP 15[ENOENT]A prefix component of the path name does not exist..TP 15[ELOOP]Too many symbolic links were encountered in translatingthe pathname..TP 15[EIO]An I/O error occurred while making the directory entryor allocating the inode..TP 15[EROFS]The name would reside on a read-only file system..TP 15[EISDIR]A null pathname was specified..SH See Alsoconnect(2), getsockname(2), listen(2), socket(2), unlink(2)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -