OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [net/] [common/] [v2_0/] [doc/] [manpages/] [sys/] [accept.2] - Diff between revs 27 and 174

Only display areas with differences | Details | Blame | View Log

Rev 27 Rev 174
.\"     $OpenBSD: accept.2,v 1.12 2001/03/11 05:02:29 aaron Exp $
.\"     $OpenBSD: accept.2,v 1.12 2001/03/11 05:02:29 aaron Exp $
.\"     $NetBSD: accept.2,v 1.7 1996/01/31 20:14:42 mycroft Exp $
.\"     $NetBSD: accept.2,v 1.7 1996/01/31 20:14:42 mycroft Exp $
.\"
.\"
.\" Copyright (c) 1983, 1990, 1991, 1993
.\" Copyright (c) 1983, 1990, 1991, 1993
.\"     The Regents of the University of California.  All rights reserved.
.\"     The Regents of the University of California.  All rights reserved.
.\"
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"    must display the following acknowledgement:
.\"     This product includes software developed by the University of
.\"     This product includes software developed by the University of
.\"     California, Berkeley and its contributors.
.\"     California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" 4. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"    without specific prior written permission.
.\"
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\" SUCH DAMAGE.
.\"
.\"
.\"     @(#)accept.2    8.2 (Berkeley) 12/11/93
.\"     @(#)accept.2    8.2 (Berkeley) 12/11/93
.\"
.\"
.Dd February 15, 1999
.Dd February 15, 1999
.Dt ACCEPT 2
.Dt ACCEPT 2
.Os
.Os
.Sh NAME
.Sh NAME
.Nm accept
.Nm accept
.Nd accept a connection on a socket
.Nd accept a connection on a socket
.Sh SYNOPSIS
.Sh SYNOPSIS
.Fd #include 
.Fd #include 
.Fd #include 
.Fd #include 
.Ft int
.Ft int
.Fn accept "int s" "struct sockaddr *addr" "socklen_t *addrlen"
.Fn accept "int s" "struct sockaddr *addr" "socklen_t *addrlen"
.Sh DESCRIPTION
.Sh DESCRIPTION
The argument
The argument
.Fa s
.Fa s
is a socket that has been created with
is a socket that has been created with
.Xr socket 2 ,
.Xr socket 2 ,
bound to an address with
bound to an address with
.Xr bind 2 ,
.Xr bind 2 ,
and is listening for connections after a
and is listening for connections after a
.Xr listen 2 .
.Xr listen 2 .
The
The
.Fn accept
.Fn accept
argument extracts the first connection request on the queue of pending
argument extracts the first connection request on the queue of pending
connections, creates a new socket with the same properties of
connections, creates a new socket with the same properties of
.Fa s ,
.Fa s ,
and allocates a new file descriptor for the socket.
and allocates a new file descriptor for the socket.
If no pending connections are present on the queue,
If no pending connections are present on the queue,
and the socket is not marked as non-blocking,
and the socket is not marked as non-blocking,
.Fn accept
.Fn accept
blocks the caller until a connection is present.
blocks the caller until a connection is present.
If the socket is marked non-blocking and no pending
If the socket is marked non-blocking and no pending
connections are present on the queue,
connections are present on the queue,
.Fn accept
.Fn accept
returns an error as described below.
returns an error as described below.
The accepted socket may not be used to accept more connections.
The accepted socket may not be used to accept more connections.
The original socket
The original socket
.Fa s
.Fa s
remains open.
remains open.
.Pp
.Pp
The argument
The argument
.Fa addr
.Fa addr
is a result parameter that is filled in with the address of the connecting
is a result parameter that is filled in with the address of the connecting
entity as known to the communications layer.
entity as known to the communications layer.
The exact format of the
The exact format of the
.Fa addr
.Fa addr
parameter is determined by the domain in which the communication
parameter is determined by the domain in which the communication
is occurring.
is occurring.
The
The
.Fa addrlen
.Fa addrlen
is a value-result parameter; it should initially contain the
is a value-result parameter; it should initially contain the
amount of space pointed to by
amount of space pointed to by
.Fa addr ;
.Fa addr ;
on return it will contain the actual length (in bytes) of the
on return it will contain the actual length (in bytes) of the
address returned.
address returned.
This call is used with connection-based socket types, currently with
This call is used with connection-based socket types, currently with
.Dv SOCK_STREAM .
.Dv SOCK_STREAM .
.Pp
.Pp
It is possible to
It is possible to
.Xr select 2
.Xr select 2
or
or
.Xr poll 2
.Xr poll 2
a socket for the purposes of doing an
a socket for the purposes of doing an
.Fn accept
.Fn accept
by selecting it for read.
by selecting it for read.
.Pp
.Pp
For certain protocols which require an explicit confirmation, such as
For certain protocols which require an explicit confirmation, such as
.Tn ISO
.Tn ISO
or
or
.Tn DATAKIT ,
.Tn DATAKIT ,
.Fn accept
.Fn accept
can be thought of as merely dequeuing the next connection
can be thought of as merely dequeuing the next connection
request and not implying confirmation.
request and not implying confirmation.
Confirmation can be implied by a normal read or write on the new file
Confirmation can be implied by a normal read or write on the new file
descriptor, and rejection can be implied by closing the new socket.
descriptor, and rejection can be implied by closing the new socket.
.Pp
.Pp
One can obtain user connection request data without confirming
One can obtain user connection request data without confirming
the connection by issuing a
the connection by issuing a
.Xr recvmsg 2
.Xr recvmsg 2
call with an
call with an
.Fa msg_iovlen
.Fa msg_iovlen
of 0 and a non-zero
of 0 and a non-zero
.Fa msg_controllen ,
.Fa msg_controllen ,
or by issuing a
or by issuing a
.Xr getsockopt 2
.Xr getsockopt 2
request.
request.
Similarly, one can provide user connection rejection information
Similarly, one can provide user connection rejection information
by issuing a
by issuing a
.Xr sendmsg 2
.Xr sendmsg 2
call with providing only the control information, or by calling
call with providing only the control information, or by calling
.Xr setsockopt 2 .
.Xr setsockopt 2 .
.Sh RETURN VALUES
.Sh RETURN VALUES
The call returns \-1 on error.
The call returns \-1 on error.
If it succeeds, it returns a non-negative integer that is a descriptor
If it succeeds, it returns a non-negative integer that is a descriptor
for the accepted socket.
for the accepted socket.
.Sh ERRORS
.Sh ERRORS
The
The
.Fn accept
.Fn accept
will fail if:
will fail if:
.Bl -tag -width Er
.Bl -tag -width Er
.It Bq Er EBADF
.It Bq Er EBADF
The descriptor is invalid.
The descriptor is invalid.
.It Bq Er ENOTSOCK
.It Bq Er ENOTSOCK
The descriptor references a file, not a socket.
The descriptor references a file, not a socket.
.It Bq Er EOPNOTSUPP
.It Bq Er EOPNOTSUPP
The referenced socket is not of type
The referenced socket is not of type
.Dv SOCK_STREAM .
.Dv SOCK_STREAM .
.It Bq Er EINVAL
.It Bq Er EINVAL
The referenced socket is not listening for connections (that is,
The referenced socket is not listening for connections (that is,
.Xr listen 2
.Xr listen 2
has not yet been called).
has not yet been called).
.It Bq Er EFAULT
.It Bq Er EFAULT
The
The
.Fa addr
.Fa addr
parameter is not in a writable part of the user address space.
parameter is not in a writable part of the user address space.
.It Bq Er EWOULDBLOCK
.It Bq Er EWOULDBLOCK
The socket is marked non-blocking and no connections
The socket is marked non-blocking and no connections
are present to be accepted.
are present to be accepted.
.It Bq Er EMFILE
.It Bq Er EMFILE
The per-process descriptor table is full.
The per-process descriptor table is full.
.It Bq Er ENFILE
.It Bq Er ENFILE
The system file table is full.
The system file table is full.
.It Bq Er ECONNABORTED
.It Bq Er ECONNABORTED
A connection has been aborted.
A connection has been aborted.
.El
.El
.Sh SEE ALSO
.Sh SEE ALSO
.Xr bind 2 ,
.Xr bind 2 ,
.Xr connect 2 ,
.Xr connect 2 ,
.Xr listen 2 ,
.Xr listen 2 ,
.Xr poll 2 ,
.Xr poll 2 ,
.Xr select 2 ,
.Xr select 2 ,
.Xr poll 2 ,
.Xr poll 2 ,
.Xr socket 2
.Xr socket 2
.Sh HISTORY
.Sh HISTORY
The
The
.Fn accept
.Fn accept
function appeared in
function appeared in
.Bx 4.2 .
.Bx 4.2 .
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.