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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [net/] [tcpip/] [v2_0/] [doc/] [accept.html] - Blame information for rev 510

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
<html>
2
<body>
3
<pre>
4
NAME
5
       accept - accept a connection on a socket
6
 
7
SYNOPSIS
8
       #include &lt;network.h&gt;
9
 
10
       int accept(int s, struct sockaddr *addr, int *addrlen);
11
 
12
DESCRIPTION
13
       The  argument  s  is  a  socket that has been created with
14
       socket(2), bound to an address with bind(2), and  is  lis-
15
       tening  for  connections  after  a  listen(2).  The accept
16
       function extracts the  first  connection  request  on  the
17
       queue  of  pending  connections, creates a new socket with
18
       the same  properties  of  s,  and  allocates  a  new  file
19
       descriptor  for the socket.  If no pending connections are
20
       present on the queue, and the socket is not marked as non-
21
       blocking,  accept  blocks the caller until a connection is
22
       present.  If the socket  is  marked  non-blocking  and  no
23
       pending  connections  are  present  on  the  queue, accept
24
       returns an error as described below.  The socket  returned
25
       by accept may not be used to accept more connections.  The
26
       original socket s remains open.
27
 
28
       The argument addr is a result parameter that is filled  in
29
       with the address of the connecting entity, as known to the
30
       communications layer.  The exact format of the addr param-
31
       eter  is  determined by the domain in which the communica-
32
       tion is occurring.  addrlen is a  value-result  parameter:
33
       it should initially contain the amount of space pointed to
34
       by addr; on return it will contain the actual  length  (in
35
       bytes)  of  the  address returned.  This call is used with
36
       connection-based socket types, currently with SOCK_STREAM.
37
 
38
       It  is  possible to select(2) a socket for the purposes of
39
       doing an accept by selecting it for read.
40
 
41
       For certain protocols which require an explicit  confirma-
42
       tion,  such  as DECNet, accept can be thought of as merely
43
       dequeuing the next connection  request  and  not  implying
44
       confirmation.   Confirmation  can  be  implied by a normal
45
       read or write on the new file  descriptor,  and  rejection
46
       can  be  implied by closing the new socket. Currently only
47
       DECNet has these semantics on Linux.
48
 
49
NOTES
50
       If you want accept to never  block  the  listening  socket
51
       needs  to  have  the  non blocking flag set. Assuming that
52
       there is always a connection waiting after select returned
53
       true  is  not  reliable,  because  the connection might be
54
       removed by  an  asynchronous  network  error  between  the
55
       select/poll returning and the accept call. The application
56
       would hang then if the listen socket is not non  blocking.
57
 
58
RETURN VALUES
59
       The  call returns -1 on error.  If it succeeds, it returns
60
       a non-negative  integer  that  is  a  descriptor  for  the
61
       accepted socket.
62
 
63
ERRORS
64
       EBADF   The descriptor is invalid.
65
 
66
       ENOTSOCK
67
               The descriptor references a file, not a socket.
68
 
69
       EOPNOTSUPP
70
               The referenced socket is not of type  SOCK_STREAM.
71
 
72
       EAGAIN  The socket is marked non-blocking and  no  connec-
73
               tions are present to be accepted.
74
 
75
       ENOBUFS, ENOMEM
76
               Not enough free memory.
77
 
78
 
79
</pre>
80
</body>
81
</html>

powered by: WebSVN 2.1.0

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