explain_socketpair(3)

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

πŸ’– explain_socketpair(3) πŸ’–

okay bestie, so this is a library functions manual page, and it's literally all about explaining the errors that socketpair(2) throws at you. no cap, it's giving "therapist for your syscalls" energy. 🫢


✨ NAME ✨

explain_socketpair β€” explain socketpair(2) errors

like, it takes a cryptic errno situation and turns it into an actual sentence you can read. πŸ’…


🌸 SYNOPSIS 🌸

#include <libexplain/socketpair.h>
const char *explain_socketpair(int domain, int type, int protocol, int
*sv);
const char *explain_errno_socketpair(int errnum, int domain, int type,
int protocol, int *sv);
void explain_message_socketpair(char *message, int message_size, int
domain, int type, int protocol, int *sv);
void explain_message_errno_socketpair(char *message, int message_size,
int errnum, int domain, int type, int protocol, int *sv);

four whole functions. four. it's a whole squad. πŸ”₯


πŸ¦‹ DESCRIPTION πŸ¦‹

so these functions? they're how you get explanations for errors that the socketpair(2) system call hands back to you. they translate the chaos into words. ✨


πŸ’œ explain_socketpair

const char *explain_socketpair(int domain, int type, int protocol, int
*sv);

the explain_socketpair function is your girl for getting an explanation of an error returned by the socketpair(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 underlying cause in way more detail. it ate. πŸ‘‘

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

  • domain β€” the original domain, exactly as passed to the socketpair(2) system call.
  • type β€” the original type, exactly as passed to the socketpair(2) system call.
  • protocol β€” the original protocol, exactly as passed to the socketpair(2) system call.
  • sv β€” the original sv, exactly as passed to the socketpair(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. πŸ’€

Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. be careful out there bestie, she's not monogamous with her buffer. 😭

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

if (socketpair(domain, type, protocol, sv) < 0)
{
    fprintf(stderr, "%s\n", explain_socketpair(domain, type,
    protocol, sv));
    exit(EXIT_FAILURE);
}

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


πŸ’– explain_errno_socketpair

const char *explain_errno_socketpair(int errnum, int domain, int type,
int protocol, int *sv);

the explain_errno_socketpair function is used to obtain an explanation of an error returned by the socketpair(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. periodt. ✨

  • 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. (rude of them, honestly. πŸ™ˆ)
  • domain β€” the original domain, exactly as passed to the socketpair(2) system call.
  • type β€” the original type, exactly as passed to the socketpair(2) system call.
  • protocol β€” the original protocol, exactly as passed to the socketpair(2) system call.
  • sv β€” the original sv, exactly as passed to the socketpair(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.

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

if (socketpair(domain, type, protocol, sv) < 0)
{
    int err = errno;
    fprintf(stderr, "%s\n", explain_errno_socketpair(err, domain,
    type, protocol, sv));
    exit(EXIT_FAILURE);
}

the above code example is available pre‐packaged as the explain_socketpair_or_die(3) function. πŸŽ€


🧚 explain_message_socketpair

void explain_message_socketpair(char *message, int message_size, int
domain, int type, int protocol, int *sv);

the explain_message_socketpair function is used to obtain an explanation of an error returned by the socketpair(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. it's giving "tell me everything, no gatekeeping". πŸ’…

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

  • message β€” the location in which to store the returned message. if a suitable message return buffer is supplied, this function is thread safe. (slay, we love a safe queen. πŸ‘‘)
  • message_size β€” the size in bytes of the location in which to store the returned message.
  • domain β€” the original domain, exactly as passed to the socketpair(2) system call.
  • type β€” the original type, exactly as passed to the socketpair(2) system call.
  • protocol β€” the original protocol, exactly as passed to the socketpair(2) system call.
  • sv β€” the original sv, exactly as passed to the socketpair(2) system call.

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

if (socketpair(domain, type, protocol, sv) < 0)
{
    char message[3000];
    explain_message_socketpair(message, sizeof(message), domain,
    type, protocol, sv);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

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


⭐ explain_message_errno_socketpair

void explain_message_errno_socketpair(char *message, int message_size,
int errnum, int domain, int type, int protocol, int *sv);

the explain_message_errno_socketpair function is used to obtain an explanation of an error returned by the socketpair(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. main character function energy fr fr. πŸ”₯

  • 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. 😀
  • domain β€” the original domain, exactly as passed to the socketpair(2) system call.
  • type β€” the original type, exactly as passed to the socketpair(2) system call.
  • protocol β€” the original protocol, exactly as passed to the socketpair(2) system call.
  • sv β€” the original sv, exactly as passed to the socketpair(2) system call.

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

if (socketpair(domain, type, protocol, sv) < 0)
{
    int err = errno;
    char message[3000];
    explain_message_errno_socketpair(message, sizeof(message),
    err, domain, type, protocol, sv);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

the above code example is available pre‐packaged as the explain_socketpair_or_die(3) function. πŸ’–


πŸ‘€ SEE ALSO πŸ‘€

like bestie, read those too. iykyk. πŸ¦‹


libexplain version 1.4 Copyright (C) 2010 Peter Miller


and that's the whole page, bestie!! πŸ’œ huge shoutout to libexplain version 1.4 and to Copyright (C) 2010 Peter Miller for making this possible β€” go off, legends, we're obsessed. and yes, the page title at the bottom is literally just explain_socketpair(3) again, bc she said "i'm my own footer, periodt." πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from