|
|
1.1 ! root 1: .\" Copyright (c) 1983 Regents of the University of California. ! 2: .\" All rights reserved. The Berkeley software License Agreement ! 3: .\" specifies the terms and conditions for redistribution. ! 4: .\" ! 5: .\" @(#)bind.2 6.6 (Berkeley) 5/22/86 ! 6: .\" ! 7: .TH BIND 2 "May 22, 1986" ! 8: .UC 5 ! 9: .SH NAME ! 10: bind \- bind a name to a socket ! 11: .SH SYNOPSIS ! 12: .nf ! 13: .ft B ! 14: #include <sys/types.h> ! 15: #include <sys/socket.h> ! 16: .PP ! 17: .ft B ! 18: bind(s, name, namelen) ! 19: int s; ! 20: struct sockaddr *name; ! 21: int namelen; ! 22: .fi ! 23: .SH DESCRIPTION ! 24: .I Bind ! 25: assigns a name to an unnamed socket. ! 26: When a socket is created ! 27: with ! 28: .IR socket (2) ! 29: it exists in a name space (address family) ! 30: but has no name assigned. ! 31: .I Bind ! 32: requests that ! 33: .IR name ! 34: be assigned to the socket. ! 35: .SH NOTES ! 36: Binding a name in the UNIX domain creates a socket in the file ! 37: system that must be deleted by the caller when it is no longer ! 38: needed (using ! 39: .IR unlink (2)). ! 40: .PP ! 41: The rules used in name binding vary between communication domains. ! 42: Consult the manual entries in section 4 for detailed information. ! 43: .SH "RETURN VALUE ! 44: If the bind is successful, a 0 value is returned. ! 45: A return value of \-1 indicates an error, which is ! 46: further specified in the global \fIerrno\fP. ! 47: .SH ERRORS ! 48: The \fIbind\fP call will fail if: ! 49: .TP 20 ! 50: [EBADF] ! 51: \fIS\fP is not a valid descriptor. ! 52: .TP 20 ! 53: [ENOTSOCK] ! 54: \fIS\fP is not a socket. ! 55: .TP 20 ! 56: [EADDRNOTAVAIL] ! 57: The specified address is not available from the local machine. ! 58: .TP 20 ! 59: [EADDRINUSE] ! 60: The specified address is already in use. ! 61: .TP 20 ! 62: [EINVAL] ! 63: The socket is already bound to an address. ! 64: .TP 20 ! 65: [EACCES] ! 66: The requested address is protected, and the current user ! 67: has inadequate permission to access it. ! 68: .TP 20 ! 69: [EFAULT] ! 70: The \fIname\fP parameter is not in a valid part of the user ! 71: address space. ! 72: .PP ! 73: The following errors are specific to binding names in the UNIX domain. ! 74: .TP 15 ! 75: [ENOTDIR] ! 76: A component of the path prefix is not a directory. ! 77: .TP 15 ! 78: [EINVAL] ! 79: The pathname contains a character with the high-order bit set. ! 80: .TP 15 ! 81: [ENAMETOOLONG] ! 82: A component of a pathname exceeded 255 characters, ! 83: or an entire path name exceeded 1023 characters. ! 84: .TP 15 ! 85: [ENOENT] ! 86: A prefix component of the path name does not exist. ! 87: .TP 15 ! 88: [ELOOP] ! 89: Too many symbolic links were encountered in translating the pathname. ! 90: .TP 15 ! 91: [EIO] ! 92: An I/O error occurred while making the directory entry or allocating the inode. ! 93: .TP 15 ! 94: [EROFS] ! 95: The name would reside on a read-only file system. ! 96: .TP 15 ! 97: [EISDIR] ! 98: A null pathname was specified. ! 99: .SH SEE ALSO ! 100: connect(2), listen(2), socket(2), getsockname(2)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.