Annotation of 43BSDTahoe/man/man2/accept.2, revision 1.1.1.1

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