Annotation of cci/usr/src/man/man2/bind.2, revision 1.1

1.1     ! root        1: .TH BIND 2 "27 July 1983"
        !             2: .UC 4
        !             3: .SH NAME
        !             4: bind \- bind a name to a socket
        !             5: .SH SYNOPSIS
        !             6: .nf
        !             7: .ft B
        !             8: #include <sys/types.h>
        !             9: #include <sys/socket.h>
        !            10: #include <sys/un.h>                /* for Unix domain only */
        !            11: #include <netinet/in.h>            /* for Internet domain only */
        !            12: .PP
        !            13: .ft B
        !            14: bind(s, name, namelen)
        !            15: int s;
        !            16: struct sockaddr *name;
        !            17: int namelen;
        !            18: .fi
        !            19: .SH DESCRIPTION
        !            20: .I Bind
        !            21: assigns a name to an unnamed socket.
        !            22: After being created by the
        !            23: .IR socket (2)
        !            24: system call, a socket
        !            25: exists in a name space (address family)
        !            26: but has no name assigned.
        !            27: .I Bind
        !            28: requests the
        !            29: .IR name
        !            30: be assigned to the socket.
        !            31: Since the system call is applicable to various communication domains,
        !            32: the address formats varies. 
        !            33: .PP
        !            34: .I BINDING NAMES TO SOCKETS IN UNIX DOMAIN
        !            35: .PP
        !            36: The system creates a file of socket type in the file system
        !            37: when binding name to a socket. This file must not have existed and
        !            38: and must be deleted by the caller when it is no longer
        !            39: needed (using
        !            40: .IR unlink (2)).
        !            41: The file created
        !            42: is a side-effect of the current implementation,
        !            43: and is not created in future versions
        !            44: of the UNIX ipc domain.
        !            45: .PP
        !            46: The argument
        !            47: .I name
        !            48: points to the following structure in the file <sys/un.h>:
        !            49: 
        !            50: .RS
        !            51: .nf
        !            52: struct sockaddr_un {
        !            53:        short   sun_family;
        !            54:        char    sun_path[109];
        !            55: };
        !            56: .fi
        !            57: .RE
        !            58: 
        !            59: .I Sun_family
        !            60: is set with AF_UNIX, and 
        !            61: .I sun_path
        !            62: is set with the socket name. The name is null terminated if it is
        !            63: less than 109 characters.
        !            64: .I Namelen
        !            65: argument must be at most 111 characters.
        !            66: 
        !            67: .I Notes
        !            68: 
        !            69: The Tahoe C-compiler operator
        !            70: .I sizeof(struct sockaddr_un)
        !            71: returns 112 (instead of 111!) since it always pads all C-structures
        !            72: to make them multiple of long words. As a result, application programmers
        !            73: must specify "sizeof(struct sockaddr_un) -1" as the value of the
        !            74: .I namelen
        !            75: argument when binding in the Unix domain.
        !            76: .PP
        !            77: .I BINDING NAMES TO SOCKETS IN INTERNET DOMAIN
        !            78: .PP
        !            79: The argument
        !            80: .I namelen
        !            81: must be at most 112.
        !            82: The argument
        !            83: .I name
        !            84: points to the following structure in the file <inet/in.h>:
        !            85: 
        !            86: .RS
        !            87: .nf
        !            88: struct sockaddr_in {
        !            89:        short    sin_family;
        !            90:        u_short  sin_port;
        !            91:        struct   in_addr   sin_addr;
        !            92:        char     sin_zero[8];
        !            93: };
        !            94: 
        !            95: .fi
        !            96: .RE
        !            97: The field 
        !            98: .I sin_port
        !            99: must be in Internet byte order.
        !           100: If the field
        !           101: .I sin_addr
        !           102: is left unspecified  (NULL value), the system will assign a default
        !           103: address. If the process reads or writes through a socket without
        !           104: binding first, the system will assign that socket a default name.
        !           105: .SH "RETURN VALUE
        !           106: If the bind is successful, a 0 value is returned.
        !           107: A return value of \-1 indicates an error, which is
        !           108: further specified in the global \fIerrno\fP.
        !           109: .SH ERRORS
        !           110: The \fIbind\fP call fails if:
        !           111: .TP 20
        !           112: [EBADF]
        !           113: \fIS\fP is not a valid descriptor.
        !           114: .TP 20
        !           115: [ENOTSOCK]
        !           116: \fIS\fP is not a socket.
        !           117: .TP 20
        !           118: [EADDRNOTAVAIL]
        !           119: The specified address is not available from the local machine.
        !           120: .TP 20
        !           121: [EADDRINUSE]
        !           122: The specified address is already in use.
        !           123: .TP 20
        !           124: [EINVAL]
        !           125: The socket is already bound to an address.
        !           126: .TP 20
        !           127: [EACCESS]
        !           128: The requested address is protected, and the current user
        !           129: has inadequate permission to access it.
        !           130: .TP 20
        !           131: [EFAULT]
        !           132: The \fIname\fP parameter is not in a valid part of the user
        !           133: address space.
        !           134: .SH SEE ALSO
        !           135: connect(2), listen(2), socket(2), getsockname(2).
        !           136: The rules used in name binding vary between communication domains.
        !           137: Consult the manual entries in section 4 for detailed information.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.