libssh2_session_disconnect_ex(3)
π libssh2_session_disconnect_ex β bestie's guide to saying bye π
okay so this is one of the libssh2 manual pages (that's the manual name btw, libssh2, we're in the big leagues) and it's literally just about hanging up on the other end of your SSH connection. gracefully. with manners. β¨
πΈ NAME πΈ
libssh2_session_disconnect_ex β terminate transport layer
like... end the convo. close the door. exit the chat. no ghosting, we do this properly. π
π SYNOPSIS π
#include <libssh2.h>
int
libssh2_session_disconnect_ex(LIBSSH2_SESSION *session, int reason,
const char *description,
const char *lang);
int
libssh2_session_disconnect(LIBSSH2_SESSION *session,
const char *description);
yes bestie there are two of them, one is the whole deluxe version and one is the little convenience macro, we'll get to that π«Ά
π¦ DESCRIPTION π¦
okay so here's the tea, parameter by parameter, no skips:
sessionβ the Session instance you got back fromlibssh2_session_init_ex(3). that's your whole connection babe, you can't just say bye into the void.reasonβ one of the Disconnect Reason constants. pick your vibe.descriptionβ a human readable reason for disconnection. like actually explain yourself, in words.langβ a localization string describing the language/encoding of thedescriptionyou just provided. yes it needs to know what language you're being dramatic in.
so what does it do? it sends a disconnect message to the remote host associated with session, and it brings along a reason symbol and a verbose description. the full package. π¦β¨
and then, as a little convenience treat, there's the macro libssh2_session_disconnect(3). it's giving "we did the work so you don't have to" β it just calls libssh2_session_disconnect_ex(3) for you with reason set to SSH_DISCONNECT_BY_APPLICATION and lang set to an empty string. lowkey the move if you don't care about customizing your goodbye. π
π RETURN VALUE π
- returns
0on success β slay, you disconnected π - returns negative on failure β the goodbye did not land π
- it returns
LIBSSH2_ERROR_EAGAINwhen it would otherwise block.
and okay, important nuance because the way people read this matters: while LIBSSH2_ERROR_EAGAIN is a negative number, it is not really a failure per se. it's not the situation being broken, it's just "not right now bestie, come back later". do not panic. do not spiral. π
π SEE ALSO π
libssh2_session_init_ex(3)β the origin story, where yoursessioncame from π
and that's the whole page fr fr. this one's from libssh2 version 0.15, dated 1 Jun 2007 β vintage but iconic, we stan a classic. bye bestie, disconnect responsibly π§π
π¦ where this page comes from
- alpine 3.22: libssh2-doc 1.11.1-r3 Β· BSD-3-Clause
- alpine 3.23: libssh2-doc 1.11.1-r4 Β· BSD-3-Clause
- alpine 3.24: libssh2-doc 1.11.1-r4 Β· BSD-3-Clause
- arch rolling: libssh2 1.11.1-7 Β· BSD-3-Clause
- debian trixie: libssh2-1-dev 1.11.1-1+deb13u1 Β· BSD3
- debian trixie: libssh2-1-dev 1.11.1-1+deb13u2 Β· BSD3
- epel 10: libssh2-docs 1.11.1-9.el10_3 Β· BSD-3-Clause
- epel 9: libssh2-docs 1.11.1-9.el9 Β· BSD-3-Clause
- fedora 43: libssh2-docs 1.11.1-4.fc43 Β· BSD-3-Clause
- fedora 43: libssh2-docs 1.11.1-9.fc43 Β· BSD-3-Clause
- fedora 44: libssh2-docs 1.11.1-5.fc44 Β· BSD-3-Clause
- fedora 44: libssh2-docs 1.11.1-9.fc44 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- ubuntu questing: libssh2-1-dev 1.11.1-1build1
- ubuntu questing: libssh2-1-dev 1.11.1-1ubuntu0.25.10.2
- ubuntu resolute: libssh2-1-dev 1.11.1-1build2 Β· BSD3
- ubuntu resolute: libssh2-1-dev 1.11.1-1ubuntu0.26.04.4 Β· BSD3
- ubuntu stonking: libssh2-1-dev 1.11.1-6 Β· BSD3
- π the page's license: BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms