libssh2_session_block_directions(3)

πŸ“¦
version 1.11.1 Β· 3 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, debian trixie, epel 10, epel 9, fedora 43, fedora 44, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ libssh2_session_block_directions ✨

okay bestie, so this is a page from the libssh2 manual β€” yes, the whole thing lives under that name β€” and today we're talking about libssh2_session_block_directions(3). it's giving "which way do i even wait" energy and honestly? kinda iconic. πŸ’…


🌸 NAME 🌸

libssh2_session_block_directions β€” get directions to wait for 🧭


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <libssh2.h>

int
libssh2_session_block_directions(LIBSSH2_SESSION *session);

πŸ’– DESCRIPTION πŸ’–

  • session β€” a Session instance, exactly the kind you get back from libssh2_session_init_ex(3). no substitutions, bestie. 🫢

so here's the tea: whenever any of the libssh2 functions hands you back LIBSSH2_ERROR_EAGAIN, that's your cue to go wait on the socket until it's got data ready to read or ready to write. 😌

and like, which one?? read? write? both?? that's literally the whole question this function answers. based on what libssh2_session_block_directions(3) gives back, you wait for read, for write, or for both. no guessing, no vibes-based socket polling. periodt. ✨


πŸ‘‘ RETURN VALUE πŸ‘‘

it returns the set of directions as a binary mask, and it can be a combination of these two:

  • LIBSSH2_SESSION_BLOCK_INBOUND β€” the inbound direction is blocked. 🚧
  • LIBSSH2_SESSION_BLOCK_OUTBOUND β€” the outbound direction is blocked. 🚧

the move is: wait for data to be available on the socket before you call a libssh2 function again. fr fr, don't skip that part. πŸ™ˆ

  • if LIBSSH2_SESSION_BLOCK_INBOUND is set, then select should contain the session socket in the readfds set. πŸ‘€
  • and correspondingly, if LIBSSH2_SESSION_BLOCK_OUTBOUND is set, the writefds set should contain the socket. ✍️

🌈 AVAILABILITY 🌈

Added in 1.0 β€” so she's been here a minute, lowkey a legend. ⭐


heads up: get the readfds / writefds thing backwards and you'll just be sitting there waiting on the wrong direction forever. not a slay. double-check that mask. πŸ’€

and that's the whole page, bestie!! this lil manual entry comes to you from the libssh2 manual, dated 1 Oct 200 (yes, that's literally what it says β€” we keep the receipts exactly as they are πŸ’–), and it's signed off by libssh2 itself. go forth and wait on the correct socket. mwah. πŸ’…πŸŽ€πŸ¦‹