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

1.1     ! root        1: .TH ACCEPT 2 "7 July 1983"
        !             2: .UC 4
        !             3: .SH NAME
        !             4: accept \- accept a connection on a socket
        !             5: .SH SYNOPSIS
        !             6: .ft B
        !             7: .nf
        !             8: #include <sys/types.h>
        !             9: #include <sys/socket.h>
        !            10: .PP
        !            11: .ft B
        !            12: ns = accept(s, addr, addrlen)
        !            13: int ns, s;
        !            14: struct sockaddr *addr;
        !            15: int *addrlen;
        !            16: .fi
        !            17: .SH DESCRIPTION
        !            18: The argument
        !            19: .I s
        !            20: is a socket which has been created with
        !            21: .IR socket (2),
        !            22: bound to an address with
        !            23: .IR bind (2),
        !            24: and is listening for connections after a
        !            25: .IR listen (2).
        !            26: .I Accept
        !            27: extracts the first connection
        !            28: on the queue of pending connections, creates
        !            29: a new socket with the same properties of 
        !            30: .I s
        !            31: and allocates a new file descriptor,
        !            32: .IR ns ,
        !            33: for the socket.  If no pending connections are
        !            34: present on the queue, and the socket is not marked
        !            35: as non-blocking,
        !            36: .I accept
        !            37: blocks the caller until a connection is present.
        !            38: If the socket is marked non-blocking and no pending
        !            39: connections are present on the queue, 
        !            40: .I accept
        !            41: returns an error as described below.
        !            42: The accepted socket,
        !            43: .IR ns ,
        !            44: may not be used
        !            45: to accept more connections.  The original socket
        !            46: .I s
        !            47: remains open.
        !            48: .PP
        !            49: The argument
        !            50: .I addr
        !            51: is a result parameter which is filled in with
        !            52: the address of the connecting entity,
        !            53: as known to the communications layer.
        !            54: The exact format of the
        !            55: .I addr
        !            56: parameter is determined by the domain in which the communication
        !            57: is occurring.
        !            58: The 
        !            59: .I addrlen
        !            60: is a value-result parameter; it should initially contain the
        !            61: amount of space pointed to by
        !            62: .IR addr ;
        !            63: on return it will contain the actual length (in bytes) of the
        !            64: address returned.
        !            65: This call
        !            66: is used with connection-based socket types, currently with SOCK_STREAM.
        !            67: .PP
        !            68: It is possible to
        !            69: .IR select (2)
        !            70: a socket for the purposes of doing an
        !            71: .I accept
        !            72: by selecting it for read.
        !            73: .SH "RETURN VALUE
        !            74: The call returns \-1 on error.  If it succeeds it returns a non-negative
        !            75: integer which is a descriptor for the accepted socket.
        !            76: .SH ERRORS
        !            77: The \fIaccept\fP will fail if:
        !            78: .TP 20
        !            79: [EBADF]
        !            80: The descriptor is invalid.
        !            81: .TP 20
        !            82: [ENOTSOCK]
        !            83: The descriptor references a file, not a socket.
        !            84: .TP 20
        !            85: [EOPNOTSUPP]
        !            86: The referenced socket is not of type SOCK_STREAM.
        !            87: .TP 20
        !            88: [EFAULT]
        !            89: The \fIaddr\fP parameter is not in a writable part of the
        !            90: user address space.
        !            91: .TP 20
        !            92: [EWOULDBLOCK]
        !            93: The socket is marked non-blocking and no connections
        !            94: are present to be accepted.
        !            95: .SH SEE ALSO
        !            96: bind(2), connect(2), listen(2), select(2), socket(2)

unix.superglobalmegacorp.com

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