explain_accept(3)

πŸ“¦
version 1.4.D001 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute

✨ explain_accept(3) ✨

okay bestie, gather round, because we're about to make sense of a manual page from the Library Functions Manual and honestly? it's giving very useful. this is explain_accept(3) and it's here to tell you why your accept(2) call said no. 🫢


🌸 NAME 🌸

explain_accept β€” the girl who explains your accept(2) errors to you, in actual human words πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <libexplain/accept.h>
const char *explain_accept(int fildes, struct sockaddr *sock_addr,
socklen_t *sock_addr_size);
const char *explain_errno_accept(int errnum, int fildes, struct sockaddr
*sock_addr, socklen_t *sock_addr_size);
void explain_message_accept(char *message, int message_size, int fildes,
struct sockaddr *sock_addr, socklen_t *sock_addrlen);
void explain_message_errno_accept(char *message, int message_size, int
errnum, int fildes, struct sockaddr *sock_addr, socklen_t
*sock_addr_size);

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, these functions exist so you can get explanations for errors handed back to you by the accept(2) system call. no more squinting at a bare number like "what does that MEAN". we decode. we elaborate. we slay. πŸ’–

✨ explain_accept ✨

const char *explain_accept(int fildes, struct sockaddr *sock_addr,
socklen_t *sock_addr_size);

explain_accept is your go-to for getting an explanation of an error returned by the accept(2) system call. the least the message will contain is the value of strerror(errno) β€” but usually it does so much better, and points at the actual underlying cause in more detail. it's giving overachiever, and we love that for it. πŸ‘‘

the errno global variable is what it reads to get the error value to decode.

this function is meant to be used in a fashion similar to this little example here:

if (accept(fildes, sock_addr, sock_addr_size) < 0)
{
    fprintf(stderr, "%s\n", explain_accept(fildes, sock_addr,
        sock_addr_size));
    exit(EXIT_FAILURE);
}

the above code example is available pre‐packaged as the explain_accept_or_die(3) function. cute, right? πŸ’…

  • fildes β€” the original fildes, exactly as passed to the accept(2) system call. no edits, no vibes-based rewrites, just as-is.
  • sock_addr β€” the original sock_addr, exactly as passed to the accept(2) system call.
  • sock_addr_size β€” the original sock_addr_size, exactly as passed to the accept(2) system call.

Returns: the message explaining the error. ⚠️ this message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. it will be overwritten by the next call to any libexplain function which shares this buffer, including other threads. so like… don't get attached to it.

Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. bestie I'm just the messenger. 😭

🌈 explain_errno_accept 🌈

const char *explain_errno_accept(int errnum, int fildes, struct sockaddr
*sock_addr, socklen_t *sock_addr_size);

explain_errno_accept is the same energy as above but for getting an explanation of an error returned by the accept(2) system call. the least the message will contain is the value of strerror(errnum), but usually it does much better and indicates the underlying cause in more detail. ✨

this one is meant to be used in a fashion similar to:

if (accept(fildes, sock_addr, sock_addr_size) < 0)
{
    int err = errno;
    fprintf(stderr, "%s\n", explain_errno_accept(err, fildes, sock_addr,
        sock_addr_size));
    exit(EXIT_FAILURE);
}

and yup, the above code example is available pre‐packaged as the explain_accept_or_die(3) function.

  • errnum β€” the error value to be decoded, usually obtained from the errno global variable just before this function is called. this is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value of errno. fr fr, guard that number with your life. 🫢
  • fildes β€” the original fildes, exactly as passed to the accept(2) system call.
  • sock_addr β€” the original sock_addr, exactly as passed to the accept(2) system call.
  • sock_addr_size β€” the original sock_addr_size, exactly as passed to the accept(2) system call.

Returns: the message explaining the error. ⚠️ this message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. this will be overwritten by the next call to any libexplain function which shares this buffer, including other threads.

Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library.

🧚 explain_message_accept 🧚

void explain_message_accept(char *message, int message_size, int fildes,
struct sockaddr *sock_addr, socklen_t *sock_addr_size);

explain_message_accept may be used to obtain an explanation of an error returned by the accept(2) system call. the least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. πŸ’–

the errno global variable will be used to obtain the error value to be decoded.

this function is intended to be used in a fashion similar to the following example:

if (accept(fildes, sock_addr, sock_addr_size) < 0)
{
    char message[3000];
    explain_message_accept(message, sizeof(message), fildes, sock_addr,
        sock_addr_size);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

the above code example is available pre‐packaged as the explain_accept_or_die(3) function.

  • message β€” the location in which to store the returned message. if a suitable message return buffer is supplied, this function is thread safe. look at her go, being all thread safe and responsible. πŸ‘‘
  • message_size β€” the size in bytes of the location in which to store the returned message.
  • fildes β€” the original fildes, exactly as passed to the accept(2) system call.
  • sock_addr β€” the original sock_addr, exactly as passed to the accept(2) system call.
  • sock_addr_size β€” the original sock_addr_size, exactly as passed to the accept(2) system call.

πŸ“ explain_message_errno_accept πŸ“

void explain_message_errno_accept(char *message, int message_size, int
errnum, int fildes, struct sockaddr *sock_addr, socklen_t
*sock_addr_size);

explain_message_errno_accept may be used to obtain an explanation of an error returned by the accept(2) system call. the least the message will contain is the value of strerror(errnum), but usually it will do much better, and indicate the underlying cause in more detail. πŸ’…

this function is intended to be used in a fashion similar to the following example:

if (accept(fildes, sock_addr, sock_addr_size) < 0)
{
    int err = errno;
    char message[3000];
    explain_message_errno_accept(message, sizeof(message), err, fildes,
        sock_addr, sock_addr_size);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

the above code example is available pre‐packaged as the explain_accept_or_die(3) function.

  • message β€” the location in which to store the returned message. if a suitable message return buffer is supplied, this function is thread safe.
  • message_size β€” the size in bytes of the location in which to store the returned message.
  • errnum β€” the error value to be decoded, usually obtained from the errno global variable just before this function is called. this is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value of errno.
  • fildes β€” the original fildes, exactly as passed to the accept(2) system call.
  • sock_addr β€” the original sock_addr, exactly as passed to the accept(2) system call.
  • sock_addr_size β€” the original sock_addr_size, exactly as passed to the accept(2) system call.

πŸ’œ SEE ALSO πŸ’œ


  • libexplain version 1.4
  • Copyright (C) 2008 Peter Miller

and that's the whole page bestie, we ate and left no crumbs πŸŽ€ sending you off with love from libexplain version 1.4 and Copyright (C) 2008 Peter Miller β€” now go read your errors, main character. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from