--- /dev/null	Sun Aug  5 23:41:09 2018
+++ new/usr/src/man/man3c/recv.3c	Sun Aug  5 23:41:09 2018
@@ -0,0 +1,259 @@
+.\"
+.\" 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) 2006, Sun Microsystems, Inc. All Rights Reserved
+.\" Copyright 2018 Nexenta Systems, Inc.
+.\"
+.Dd August 2, 2018
+.Dt RECV 3C
+.Os
+.Sh NAME
+.Nm recv ,
+.Nm recvfrom ,
+.Nm recvmsg
+.Nd receive a message from a socket
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/socket.h
+.In sys/uio.h
+.Ft ssize_t
+.Fo recv
+.Fa "int s"
+.Fa "void *buf"
+.Fa "size_t len"
+.Fa "int flags"
+.Fc
+.Ft ssize_t
+.Fo recvfrom
+.Fa "int s"
+.Fa "void *restrict buf"
+.Fa "size_t len"
+.Fa "int flags"
+.Fa "struct sockaddr *restrict from"
+.Fa "socklen_t *fromlen"
+.Fc
+.Ft ssize_t
+.Fo recvmsg
+.Fa "int s"
+.Fa "struct msghdr *msg"
+.Fa "int flags"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn recv ,
+.Fn recvfrom ,
+and
+.Fn recvmsg
+functions are used to receive messages from another socket.
+The
+.Fa s
+socket is created with
+.Xr socket 3C .
+.Pp
+If
+.Fa from
+is a non-
+.Dv NULL
+pointer, the source address of the message is filled in.
+The value-result parameter
+.Fa fromlen
+is initialized to the size of the buffer associated with
+.Fa from
+and modified on return to indicate the actual size of the address stored in the
+buffer.
+The length of the message is returned.
+If a message is too long to fit in the supplied buffer, excess bytes may be
+discarded depending on the type of socket from which the message is received.
+See
+.Xr socket 3C .
+.Pp
+If no messages are available at the socket, the receive call waits for a message
+to arrive.
+If the socket is non-blocking, -1 is returned with the external variable
+.Va errno
+set to
+.Er EWOULDBLOCK .
+See
+.Xr fcntl 2 .
+.Pp
+For processes on the same host,
+.Fn recvmsg
+can be used to receive a file descriptor from another process, but it cannot
+receive ancillary data.
+See
+.Xr libxnet 3LIB .
+.Pp
+If a zero-length buffer is specified for a message, an EOF condition results
+that is indistinguishable from the successful transfer of a file descriptor.
+For that reason, one or more bytes of data should be provided when
+.Fn recvmsg
+passes a file descriptor.
+.Pp
+The
+.Xr select 3C
+call can be used to determine when more data arrives.
+.Pp
+The
+.Fa flags
+parameter is formed by an OR operation on one or more of the following:
+.Bl -tag -width Ds
+.It Dv MSG_OOB
+Read any out-of-band data present on the socket rather than the regular in-band
+data.
+.It Dv MSG_PEEK
+Peek at the data present on the socket.
+The data is returned, but not consumed to allow a subsequent receive operation
+to see the same data.
+.It Dv MSG_WAITALL
+Messages are blocked until the full amount of data requested is returned.
+The
+.Fn recv
+function can return a smaller amount of data if a signal is caught, the
+connection is terminated,
+.Dv MSG_PEEK
+is specified, or if an error is pending for the socket.
+.It Dv MSG_DONTWAIT
+Pending messages received on the connection are returned.
+If data is unavailable, the function does not block.
+This behavior is the equivalent to specifying
+.Dv O_NONBLOCK
+on the file descriptor of a socket, except that write requests are unaffected.
+.El
+.Pp
+The
+.Fn recvmsg
+function call uses a
+.Va msghdr
+structure defined in
+.In sys/socket.h
+to minimize the number of directly supplied parameters.
+.Sh RETURN VALUES
+Upon successful completion, these functions return the number of bytes
+received.
+Otherwise, they return -1 and set
+.Va errno
+to indicate the error.
+.Sh ERRORS
+The
+.Fn recv ,
+.Fn recvfrom ,
+and
+.Fn recvmsg
+functions return errors under the following conditions:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa s
+file descriptor is invalid.
+.It Bq Er ECONNRESET
+The
+.Fa s
+argument refers to a connection oriented socket and the connection was forcibly
+closed by the peer and is no longer valid.
+I/O can no longer be performed to filedes.
+.It Bq Er EINVAL
+The
+.Dv MSG_OOB
+flag is set and no out-of-band data is available.
+.It Bq Er EINTR
+The operation is interrupted by the delivery of a signal before any data is
+available to be received.
+.It Bq Er EIO
+An I/O error occurs while reading from or writing to the file system.
+.It Bq Er ENOMEM
+Insufficient user memory is available to complete operation.
+.It Bq Er ENOSR
+Insufficient STREAMS resources are available for the operation to complete.
+.It Bq Er ENOTSOCK
+.Fa s
+is not a socket.
+.It Bq Er ESTALE
+A stale NFS file handle exists.
+.It Bq Er EWOULDBLOCK
+The socket is marked non-blocking and the requested operation would block.
+.It Bq Er ECONNREFUSED
+The requested connection was refused by the peer.
+For connected IPv4 and IPv6 datagram sockets, this indicates that the system
+received an ICMP
+.Dq Destination Port Unreachable
+message from the peer.
+.El
+.Pp
+The
+.Fn recv
+and
+.Fn recvfrom
+functions fail under the following conditions:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa len
+argument overflows a
+.Vt ssize_t .
+.El
+.Pp
+The
+.Fn recvmsg
+function returns errors under the following conditions:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Va msg_iovlen
+member of the
+.Va msghdr
+structure pointed to by
+.Fa msg
+is less than or equal to 0, or greater than
+.Dv [IOV_MAX} .
+See
+.Xr Intro 2
+for a definition of
+.Dv [IOV_MAX} .
+.Pp
+One of the
+.Va iov_len
+values in the
+.Va msg_iov
+array member of the
+.Va msghdr
+structure pointed to by
+.Fa msg
+is negative, or the sum of the
+.Va iov_len
+values in the
+.Va msg_iov
+array overflows a
+.Vt ssize_t .
+.El
+.Sh MT-LEVEL
+.Sy Safe
+.Sh SEE ALSO
+.Xr fcntl 2 ,
+.Xr ioctl 2 ,
+.Xr read 2 ,
+.Xr connect 3C ,
+.Xr getsockopt 3C ,
+.Xr select 3C ,
+.Xr send 3C ,
+.Xr sockaddr 3C ,
+.Xr socket 3C ,
+.Xr socket.h 3HEAD ,
+.Xr libxnet 3LIB ,
+.Xr attributes 5
