1explain_accept(3)          Library Functions Manual          explain_accept(3)
2
3
4

NAME

6       explain_accept - explain accept(2) errors
7

SYNOPSIS

9       #include <libexplain/accept.h>
10       const  char  *explain_accept(int  fildes,  struct  sockaddr *sock_addr,
11       socklen_t *sock_addr_size);
12       const char *explain_errno_accept(int errnum, int fildes,  struct  sock‐
13       addr *sock_addr, socklen_t *sock_addr_size);
14       void   explain_message_accept(char   *message,  int  message_size,  int
15       fildes, struct sockaddr *sock_addr, socklen_t *sock_addrlen);
16       void explain_message_errno_accept(char *message, int message_size,  int
17       errnum,    int    fildes,   struct   sockaddr   *sock_addr,   socklen_t
18       *sock_addr_size);
19

DESCRIPTION

21       These functions may be used to obtain explanations for errors  returned
22       by the accept(2) system call.
23
24   explain_accept
25       const  char  *explain_accept(int  fildes,  struct  sockaddr *sock_addr,
26       socklen_t *sock_addr_size);
27
28       The explain_accept function is used to  obtain  an  explanation  of  an
29       error  returned  by  the  accept(2) system call.  The least the message
30       will contain is the value of strerror(errno), but usually  it  will  do
31       much better, and indicate the underlying cause in more detail.
32
33       The  errno global variable will be used to obtain the error value to be
34       decoded.
35
36       This function is intended to be used in a fashion similar to  the  fol‐
37       lowing example:
38              if (accept(fildes, sock_addr, sock_addr_size) < 0)
39              {
40                  fprintf(stderr, "%s\n", explain_accept(fildes, sock_addr,
41                      sock_addr_size));
42                  exit(EXIT_FAILURE);
43              }
44
45       The   above   code   example   is   available   pre‐packaged   as   the
46       explain_accept_or_die(3) function.
47
48       fildes  The original fildes, exactly as passed to the accept(2)  system
49               call.
50
51       sock_addr
52               The original sock_addr, exactly as passed to the accept(2) sys‐
53               tem call.
54
55       sock_addr_size
56               The original sock_addr_size, exactly as passed to the accept(2)
57               system call.
58
59       Returns:
60               The  message  explaining  the  error.   This  message buffer is
61               shared by all libexplain functions which do not supply a buffer
62               in  their  argument list.  This will be overwritten by the next
63               call to any  libexplain  function  which  shares  this  buffer,
64               including other threads.
65
66       Note: This function is not thread safe, because it shares a return buf‐
67       fer across all threads, and many other functions in this library.
68
69   explain_errno_accept
70       const char *explain_errno_accept(int errnum, int fildes,  struct  sock‐
71       addr *sock_addr, socklen_t *sock_addr_size);
72
73       The  explain_errno_accept  function is used to obtain an explanation of
74       an error returned by the accept(2) system call.  The least the  message
75       will  contain  is the value of strerror(errnum), but usually it will do
76       much better, and indicate the underlying cause in more detail.
77
78       This function is intended to be used in a fashion similar to  the  fol‐
79       lowing example:
80              if (accept(fildes, sock_addr, sock_addr_size) < 0)
81              {
82                  int err = errno;
83                  fprintf(stderr, "%s\n", explain_errno_accept(err, fildes, sock_addr,
84                      sock_addr_size));
85                  exit(EXIT_FAILURE);
86              }
87
88       The   above   code   example   is   available   pre‐packaged   as   the
89       explain_accept_or_die(3) function.
90
91       errnum  The error value to be decoded, usually obtained from the  errno
92               global  variable  just before this function is called.  This is
93               necessary if you need to call any code between the system  call
94               to  be explained and this function, because many libc functions
95               will alter the value of errno.
96
97       fildes  The original fildes, exactly as passed to the accept(2)  system
98               call.
99
100       sock_addr
101               The original sock_addr, exactly as passed to the accept(2) sys‐
102               tem call.
103
104       sock_addr_size
105               The original sock_addr_size, exactly as passed to the accept(2)
106               system call.
107
108       Returns:
109               The  message  explaining  the  error.   This  message buffer is
110               shared by all libexplain functions which do not supply a buffer
111               in  their  argument list.  This will be overwritten by the next
112               call to any  libexplain  function  which  shares  this  buffer,
113               including other threads.
114
115       Note: This function is not thread safe, because it shares a return buf‐
116       fer across all threads, and many other functions in this library.
117
118   explain_message_accept
119       void  explain_message_accept(char  *message,  int   message_size,   int
120       fildes, struct sockaddr *sock_addr, socklen_t *sock_addr_size);
121
122       The  explain_message_accept function may be used to  obtain an explana‐
123       tion of an error returned by the accept(2) system call.  The least  the
124       message  will  contain  is the value of strerror(errno), but usually it
125       will do much better, and indicate the underlying cause in more detail.
126
127       The errno global variable will be used to obtain the error value to  be
128       decoded.
129
130       This  function  is intended to be used in a fashion similar to the fol‐
131       lowing example:
132              if (accept(fildes, sock_addr, sock_addr_size) < 0)
133              {
134                  char message[3000];
135                  explain_message_accept(message, sizeof(message), fildes, sock_addr,
136                      sock_addr_size);
137                  fprintf(stderr, "%s\n", message);
138                  exit(EXIT_FAILURE);
139              }
140
141       The   above   code   example   is   available   pre‐packaged   as   the
142       explain_accept_or_die(3) function.
143
144       message The  location  in  which  to  store the returned message.  If a
145               suitable message return buffer is supplied,  this  function  is
146               thread safe.
147
148       message_size
149               The  size  in  bytes  of  the  location  in  which to store the
150               returned message.
151
152       fildes  The original fildes, exactly as passed to the accept(2)  system
153               call.
154
155       sock_addr
156               The original sock_addr, exactly as passed to the accept(2) sys‐
157               tem call.
158
159       sock_addr_size
160               The original sock_addr_size, exactly as passed to the accept(2)
161               system call.
162
163   explain_message_errno_accept
164       void  explain_message_errno_accept(char *message, int message_size, int
165       errnum,   int   fildes,   struct   sockaddr    *sock_addr,    socklen_t
166       *sock_addr_size);
167
168       The  explain_message_errno_accept  function  may  be  used to obtain an
169       explanation of an error returned by the  accept(2)  system  call.   The
170       least  the  message  will contain is the value of strerror(errnum), but
171       usually it will do much better, and indicate the  underlying  cause  in
172       more detail.
173
174       This  function  is intended to be used in a fashion similar to the fol‐
175       lowing example:
176              if (accept(fildes, sock_addr, sock_addr_size) < 0)
177              {
178                  int err = errno;
179                  char message[3000];
180                  explain_message_errno_accept(message, sizeof(message), err, fildes,
181                      sock_addr, sock_addr_size);
182                  fprintf(stderr, "%s\n", message);
183                  exit(EXIT_FAILURE);
184              }
185
186       The   above   code   example   is   available   pre‐packaged   as   the
187       explain_accept_or_die(3) function.
188
189       message The  location  in  which  to  store the returned message.  If a
190               suitable message return buffer is supplied,  this  function  is
191               thread safe.
192
193       message_size
194               The  size  in  bytes  of  the  location  in  which to store the
195               returned message.
196
197       errnum  The error value to be decoded, usually obtained from the  errno
198               global  variable  just before this function is called.  This is
199               necessary if you need to call any code between the system  call
200               to  be explained and this function, because many libc functions
201               will alter the value of errno.
202
203       fildes  The original fildes, exactly as passed to the accept(2)  system
204               call.
205
206       sock_addr
207               The original sock_addr, exactly as passed to the accept(2) sys‐
208               tem call.
209
210       sock_addr_size
211               The original sock_addr_size, exactly as passed to the accept(2)
212               system call.
213

SEE ALSO

215       accept(2)
216               accept a connection on a socket
217
218       explain_accept_or_die(3)
219               accept a connection on a socket and report errors
220
222       libexplain version 1.4
223       Copyright (C) 2008 Peter Miller
224
225
226
227                                                             explain_accept(3)
Impressum