--- /dev/null	Sun Aug  5 23:41:08 2018
+++ new/usr/src/man/man3c/accept.3c	Sun Aug  5 23:41:08 2018
@@ -0,0 +1,263 @@
+.\"
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.\"
+.\"
+.\" Copyright 1989 AT&T
+.\" Copyright (C) 2002, Sun Microsystems, Inc. All Rights Reserved
+.\" Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
+.\" Copyright 2018 Nexenta Systems, Inc.
+.\"
+.Dd August 2, 2018
+.Dt ACCEPT 3C
+.Os
+.Sh NAME
+.Nm accept
+.Nd accept a connection on a socket
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/socket.h
+.Ft int
+.Fo accept
+.Fa "int s"
+.Fa "struct sockaddr *restrict addr"
+.Fa "socklen_t *addrlen"
+.Fc
+.Ft int
+.Fo accept4
+.Fa "int s"
+.Fa "struct sockaddr *restrict addr"
+.Fa "socklen_t *addrlen"
+.Fa "int flags"
+.Fc
+.Sh DESCRIPTION
+The argument
+.Fa s
+is a socket that has been created with
+.Xr socket 3C
+and bound to an address with
+.Xr bind 3C ,
+and that is listening for connections after a call to
+.Xr listen 3C .
+The
+.Fn accept
+function extracts the first connection on the queue of pending connections,
+creates a new socket with the properties of
+.Fa s ,
+and allocates a new file descriptor,
+.Va ns ,
+for the socket.
+If no pending connections are present on the queue and the socket is not marked
+as non-blocking,
+.Fn accept
+blocks the caller until a connection is present.
+If the socket is marked as non-blocking and no pending connections are present
+on the queue,
+.Fn accept
+returns an error as described below.
+The
+.Fn accept
+function uses the
+.Xr netconfig 4
+file to determine the STREAMS device file name associated with
+.Fa s .
+This is the device on which the connect indication will be accepted.
+The accepted socket,
+.Va ns ,
+is used to read and write data to and from the socket that connected to
+.Va ns .
+It is not used to accept more connections.
+The original socket
+.Pq Fa s
+remains open for accepting further connections.
+.Pp
+The argument
+.Fa addr
+is a result parameter that is filled in with the address of the connecting
+entity as it is known to the communications layer.
+The exact format of the
+.Fa addr
+parameter is determined by the domain in which the communication occurs.
+.Pp
+The argument
+.Fa addrlen
+is a value-result parameter.
+Initially, it contains the amount of space pointed to by
+.Fa addr ;
+on return it contains the length in bytes of the address returned.
+.Pp
+The
+.Fn accept
+function is used with connection-based socket types, currently with
+.Dv SOCK_STREAM .
+.Pp
+The
+.Fn accept4
+function allows flags that control the behavior of a successfully accepted
+socket.
+If
+.Fa flags
+is 0,
+.Fn accept4
+acts identically to
+.Fn accept .
+Values for
+.Fa flags
+are constructed by a bitwise-inclusive-OR of flags from the following list,
+defined in
+.In sys/socketvar.h :
+.Bl -tag -width Ds
+.It Dv SOCK_CLOEXEC
+The accepted socket will have the
+.Dv FD_CLOEXEC
+flag set as if
+.Xr fcntl 2
+was called on it.
+This flag is set before the socket is passed to the caller thus avoiding the
+race condition between
+.Fn accept
+and
+.Xr fcntl 2 .
+See
+.Dv O_CLOEXEC
+in
+.Xr open 2
+for more details.
+.It Dv SOCK_NDELAY
+The accepted socket will have the
+.Dv O_NDELAY
+flag set as if
+.Xr fcntl 2
+was called on it.
+This sets the socket into non-blocking mode.
+See
+.Dv O_NDELAY
+in
+.Xr fcntl.h 3HEAD
+for more details.
+.It Dv SOCK_NONBLOCK
+The accepted socket will have the
+.Dv O_NONBLOCK
+flag set as if
+.Xr fcntl 2
+was called on it.
+This sets the socket into non-blocking mode
+.Po POSIX; see
+.Xr standards 5
+.Pc .
+See
+.Dv O_NONBLOCK
+in
+.Xr fcntl.h 3HEAD
+for more details.
+.El
+.Pp
+It is possible to
+.Xr select 3C
+or
+.Xr poll 2
+a socket for the purpose of an
+.Fn accept
+by selecting or polling it for a read.
+However, this will only indicate when a connect indication is pending; it is
+still necessary to call
+.Fn accept .
+.Sh RETURN VALUES
+The
+.Fn accept
+function returns -1 on error.
+If it succeeds, it returns a non-negative integer that is a descriptor for the
+accepted socket.
+.Sh ERRORS
+.Fn accept
+and
+.Fn accept4
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The descriptor is invalid.
+.It Bq Er ECONNABORTED
+The remote side aborted the connection before the
+.Fn accept
+operation completed.
+.It Bq Er EFAULT
+The
+.Fa addr
+parameter or the
+.Fa addrlen
+parameter is invalid.
+.It Bq Er EINTR
+The
+.Fn accept
+attempt was interrupted by the delivery of a signal.
+.It Bq Er EMFILE
+The per-process descriptor table is full.
+.It Bq Er ENODEV
+The protocol family and type corresponding to
+.Fa s
+could not be found in the
+.Pa netconfig
+file.
+.It Bq Er ENOMEM
+There was insufficient user memory available to complete the operation.
+.It Bq Er ENOSR
+There were insufficient STREAMS resources available to complete the operation.
+.It Bq Er ENOTSOCK
+The descriptor does not reference a socket.
+.It Bq Er EOPNOTSUPP
+The referenced socket is not of type
+.Dv SOCK_STREAM .
+.It Bq Er EPROTO
+A protocol error has occurred; for example, the STREAMS protocol stack has not
+been initialized or the connection has already been released.
+.It Bq Er EWOULDBLOCK
+The socket is marked as non-blocking and no connections are present to be
+accepted.
+.El
+.Pp
+Additionally,
+.Fn accept4
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa flags
+value is invalid.
+The
+.Fa flags
+argument can only be the bitwise inclusive-OR of
+.Dv SOCK_CLOEXEC ,
+.Dv SOCK_NONBLOCK ,
+and
+.Dv SOCK_NDELAY .
+.El
+.Sh MT-LEVEL
+.Sy Safe
+.Sh SEE ALSO
+.Xr fcntl 2 ,
+.Xr poll 2 ,
+.Xr bind 3C ,
+.Xr connect 3C ,
+.Xr listen 3C ,
+.Xr select 3C ,
+.Xr sockaddr 3C ,
+.Xr socket 3C ,
+.Xr fcntl.h 3HEAD ,
+.Xr socket.h 3HEAD ,
+.Xr netconfig 4 ,
+.Xr attributes 5 ,
+.Xr standards 5
