libssh2_session_set_blocking(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_set_blocking β€” the glow-up your session needed

okay bestie, welcome to the libssh2 manual page for libssh2_session_set_blocking(3) ✨ this one is a tiny little function with main character energy: it flips your session between blocking and non-blocking mode and literally everything downstream feels it. no cap. πŸ¦‹


🌸 NAME 🌸

libssh2_session_set_blocking β€” set or clear blocking mode on session πŸŽ€


✨ SYNOPSIS ✨

#include <libssh2.h>

void
libssh2_session_set_blocking(LIBSSH2_SESSION *session, int blocking);

πŸ’– DESCRIPTION πŸ’–

here's the tea, and there are exactly two things you're handing over:

  • session β€” your session instance, the one you got back from libssh2_session_init_ex(3). yes, that one. 🫢
  • blocking β€” set it to a non-zero value to make the channel block, or set it to zero to make it non-blocking. that's the whole vibe check right there.

so what does it actually do?? it sets or clears the blocking mode on the selected session, and the way that it works is instant β€” any channels associated with this session are affected immediately. no waiting, no queue, no "let me think about it". periodt. πŸ’…

now for the behaviour, because this is the part that matters:

  • if a read happens on a session and there's no data currently available, a blocking session will wait for data to arrive and return what it receives. it's giving patient queen. πŸ‘‘
  • a non-blocking session will return immediately with an empty buffer instead. it's giving "not my problem, moving on". πŸ’€
  • if a write happens on a session and there's no room for more data, a blocking session will wait for room. so cozy. so committed. 🌸
  • a non-blocking session will return immediately without writing anything at all. zero notes. just gone. πŸ™ˆ
bestie listen β€” blocking mode means your code can just sit there waiting. non-blocking means it never waits for you. pick based on what your program is doing, not on vibes alone. (okay, a little on vibes.)

πŸŽ€ RETURN VALUE πŸŽ€

None. literally nothing comes back. it does its little job and that's it. iconic behaviour honestly ⭐


πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page, bestie!! go forth and set your blocking mode with confidence πŸ’œ

this was libssh2 version 0.15, dated 1 Jun 2007, and the manual section is libssh2_session_set_blocking(3). mwah. πŸ˜­πŸ’–