libssh2_sftp_close_handle(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_sftp_close_handle(3) ✨

okay bestie, gather round, we're closing file handles today and honestly? it's giving closure πŸŽ€ this one lives in the libssh2 manual and it's the glow-up your SFTP session needs when you're done with it πŸ’…


πŸ’– NAME πŸ’–

libssh2_sftp_close_handle β€” close filehandle 🫢


🌸 SYNOPSIS 🌸

#include <libssh2.h>
#include <libssh2_sftp.h>

int
libssh2_sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle);

int
libssh2_sftp_close(LIBSSH2_SFTP_HANDLE *handle);

int
libssh2_sftp_closedir(LIBSSH2_SFTP_HANDLE *handle);

πŸ¦‹ DESCRIPTION πŸ¦‹

handle β€” the SFTP File Handle, aka the little token you got handed back from libssh2_sftp_open_ex(3) or libssh2_sftp_opendir(3) (and psst, that last one is a macro πŸ‘€).

So what are we doing here? We're closing an active LIBSSH2_SFTP_HANDLE. And here's the iconic part: because files and directories share the same underlying storage mechanism, these methods are literally interchangeable, no cap. libssh2_sftp_close(3) and libssh2_sftp_closedir(3) are both macros for libssh2_sftp_close_handle(3). Same vibe, same function, three names. main character energy fr fr ✨


πŸ”₯ RETURN VALUE πŸ”₯

  • Returns 0 on success, or a negative number on failure. πŸ’€
  • It returns LIBSSH2_ERROR_EAGAIN when it would otherwise block.
okay important: LIBSSH2_ERROR_EAGAIN is a negative number, yes, but it is not really a failure per se. It's just the function saying "not yet bestie, try again later" 😌 don't panic, it's not a real L.

😭 ERRORS 😭

  • LIBSSH2_ERROR_ALLOC β€” an internal memory allocation call failed. the malloc said no πŸ™ˆ
  • LIBSSH2_ERROR_SOCKET_SEND β€” unable to send data on socket. the socket is not picking up the phone πŸ“΅
  • LIBSSH2_ERROR_SOCKET_TIMEOUT β€”
  • LIBSSH2_ERROR_SFTP_PROTOCOL β€” an invalid SFTP protocol response was received on the socket, or an SFTP operation caused an errorcode to be returned by the server. server said something unhinged and we're not entertaining it πŸ’…

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page bestie, you ate that πŸ“ go close some handles responsibly, hydrate, and remember: three names, one function, zero drama ✨

libssh2 0.15 Β· 1 Jun 2007 β€” yeah this page is vintage, it's been iconic since 2007 and it still slays πŸ’– mwah, bye 🫢