]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - doc/html/ref/net-common-tcpip-manpages-accept.html
Initial revision
[karo-tx-redboot.git] / doc / html / ref / net-common-tcpip-manpages-accept.html
1 <!-- Copyright (C) 2003 Red Hat, Inc.                                -->
2 <!-- This material may be distributed only subject to the terms      -->
3 <!-- and conditions set forth in the Open Publication License, v1.0  -->
4 <!-- or later (the latest version is presently available at          -->
5 <!-- http://www.opencontent.org/openpub/).                           -->
6 <!-- Distribution of the work or derivative of the work in any       -->
7 <!-- standard (paper) book form is prohibited unless prior           -->
8 <!-- permission is obtained from the copyright holder.               -->
9 <HTML
10 ><HEAD
11 ><TITLE
12 >accept</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
14 <META
15 NAME="GENERATOR"
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
17 "><LINK
18 REL="HOME"
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
21 REL="UP"
22 TITLE="TCP/IP Library Reference"
23 HREF="tcpip-library-reference.html"><LINK
24 REL="PREVIOUS"
25 TITLE="resolver"
26 HREF="net-common-tcpip-manpages-resolver.html"><LINK
27 REL="NEXT"
28 TITLE="bind"
29 HREF="net-common-tcpip-manpages-bind.html"></HEAD
30 ><BODY
31 CLASS="SECT1"
32 BGCOLOR="#FFFFFF"
33 TEXT="#000000"
34 LINK="#0000FF"
35 VLINK="#840084"
36 ALINK="#0000FF"
37 ><DIV
38 CLASS="NAVHEADER"
39 ><TABLE
40 SUMMARY="Header navigation table"
41 WIDTH="100%"
42 BORDER="0"
43 CELLPADDING="0"
44 CELLSPACING="0"
45 ><TR
46 ><TH
47 COLSPAN="3"
48 ALIGN="center"
49 >eCos Reference Manual</TH
50 ></TR
51 ><TR
52 ><TD
53 WIDTH="10%"
54 ALIGN="left"
55 VALIGN="bottom"
56 ><A
57 HREF="net-common-tcpip-manpages-resolver.html"
58 ACCESSKEY="P"
59 >Prev</A
60 ></TD
61 ><TD
62 WIDTH="80%"
63 ALIGN="center"
64 VALIGN="bottom"
65 >Chapter 38. TCP/IP Library Reference</TD
66 ><TD
67 WIDTH="10%"
68 ALIGN="right"
69 VALIGN="bottom"
70 ><A
71 HREF="net-common-tcpip-manpages-bind.html"
72 ACCESSKEY="N"
73 >Next</A
74 ></TD
75 ></TR
76 ></TABLE
77 ><HR
78 ALIGN="LEFT"
79 WIDTH="100%"></DIV
80 ><DIV
81 CLASS="SECT1"
82 ><H1
83 CLASS="SECT1"
84 ><A
85 NAME="NET-COMMON-TCPIP-MANPAGES-ACCEPT">accept</H1
86 ><TABLE
87 BORDER="5"
88 BGCOLOR="#E0E0F0"
89 WIDTH="70%"
90 ><TR
91 ><TD
92 ><PRE
93 CLASS="SCREEN"
94 >ACCEPT(2)                     System Calls Manual                    ACCEPT(2)
95
96 NAME
97      accept - accept a connection on a socket
98
99 SYNOPSIS
100      #include &lt;sys/types.h&#62;
101      #include &lt;sys/socket.h&#62;
102
103      int
104      accept(int s, struct sockaddr *addr, socklen_t *addrlen);
105
106 DESCRIPTION
107      The argument s is a socket that has been created with socket(2), bound to
108      an address with bind(2), and is listening for connections after a
109      listen(2).  The accept() argument extracts the first connection request
110      on the queue of pending connections, creates a new socket with the same
111      properties of s, and allocates a new file descriptor for the socket.  If
112      no pending connections are present on the queue, and the socket is not
113      marked as non-blocking, accept() blocks the caller until a connection is
114      present.  If the socket is marked non-blocking and no pending connections
115      are present on the queue, accept() returns an error as described below.
116      The accepted socket may not be used to accept more connections.  The
117      original socket s remains open.
118
119      The argument addr is a result parameter that is filled in with the
120      address of the connecting entity as known to the communications layer.
121      The exact format of the addr parameter is determined by the domain in
122      which the communication is occurring.  The addrlen is a value-result
123      parameter; it should initially contain the amount of space pointed to by
124      addr; on return it will contain the actual length (in bytes) of the
125      address returned.  This call is used with connection-based socket types,
126      currently with SOCK_STREAM.
127
128      It is possible to select(2) or poll(2) a socket for the purposes of doing
129      an accept() by selecting it for read.
130
131      For certain protocols which require an explicit confirmation, such as ISO
132      or DATAKIT, accept() can be thought of as merely dequeuing the next con-
133      nection request and not implying confirmation.  Confirmation can be
134      implied by a normal read or write on the new file descriptor, and rejec-
135      tion can be implied by closing the new socket.
136
137      One can obtain user connection request data without confirming the con-
138      nection by issuing a recvmsg(2) call with an msg_iovlen of 0 and a non-
139      zero msg_controllen, or by issuing a getsockopt(2) request.  Similarly,
140      one can provide user connection rejection information by issuing a
141      sendmsg(2) call with providing only the control information, or by call-
142      ing setsockopt(2).
143
144 RETURN VALUES
145      The call returns -1 on error.  If it succeeds, it returns a non-negative
146      integer that is a descriptor for the accepted socket.
147
148 ERRORS
149      The accept() will fail if:
150
151      [EBADF]            The descriptor is invalid.
152
153      [ENOTSOCK]         The descriptor references a file, not a socket.
154
155      [EOPNOTSUPP]       The referenced socket is not of type SOCK_STREAM.
156
157      [EINVAL]           The referenced socket is not listening for connections
158                         (that is, listen(2) has not yet been called).
159
160      [EFAULT]           The addr parameter is not in a writable part of the
161                         user address space.
162
163      [EWOULDBLOCK]      The socket is marked non-blocking and no connections
164                         are present to be accepted.
165
166      [EMFILE]           The per-process descriptor table is full.
167
168      [ENFILE]           The system file table is full.
169
170      [ECONNABORTED]     A connection has been aborted.
171
172 SEE ALSO
173      bind(2), connect(2), listen(2), poll(2), select(2), poll(2), socket(2)
174
175 HISTORY
176      The accept() function appeared in 4.2BSD.
177
178 BSD                            February 15, 1999                           BSD
179     </PRE
180 ></TD
181 ></TR
182 ></TABLE
183 ></DIV
184 ><DIV
185 CLASS="NAVFOOTER"
186 ><HR
187 ALIGN="LEFT"
188 WIDTH="100%"><TABLE
189 SUMMARY="Footer navigation table"
190 WIDTH="100%"
191 BORDER="0"
192 CELLPADDING="0"
193 CELLSPACING="0"
194 ><TR
195 ><TD
196 WIDTH="33%"
197 ALIGN="left"
198 VALIGN="top"
199 ><A
200 HREF="net-common-tcpip-manpages-resolver.html"
201 ACCESSKEY="P"
202 >Prev</A
203 ></TD
204 ><TD
205 WIDTH="34%"
206 ALIGN="center"
207 VALIGN="top"
208 ><A
209 HREF="ecos-ref.html"
210 ACCESSKEY="H"
211 >Home</A
212 ></TD
213 ><TD
214 WIDTH="33%"
215 ALIGN="right"
216 VALIGN="top"
217 ><A
218 HREF="net-common-tcpip-manpages-bind.html"
219 ACCESSKEY="N"
220 >Next</A
221 ></TD
222 ></TR
223 ><TR
224 ><TD
225 WIDTH="33%"
226 ALIGN="left"
227 VALIGN="top"
228 >resolver</TD
229 ><TD
230 WIDTH="34%"
231 ALIGN="center"
232 VALIGN="top"
233 ><A
234 HREF="tcpip-library-reference.html"
235 ACCESSKEY="U"
236 >Up</A
237 ></TD
238 ><TD
239 WIDTH="33%"
240 ALIGN="right"
241 VALIGN="top"
242 >bind</TD
243 ></TR
244 ></TABLE
245 ></DIV
246 ></BODY
247 ></HTML
248 >