libssh2_sftp_read(3)
π libssh2_sftp_read(3) π
okay bestie, welcome to the libssh2 manual page for libssh2_sftp_read β she's the one who pulls actual data out of your SFTP handle, and honestly? iconic. π¦
β¨ NAME β¨
libssh2_sftp_read β read data from an SFTP handle πΈ
β¨ SYNOPSIS β¨
#include <libssh2.h>
#include <libssh2_sftp.h>
ssize_t
libssh2_sftp_read(LIBSSH2_SFTP_HANDLE *handle,
char *buffer, size_t buffer_maxlen);
β¨ DESCRIPTION β¨
okay so. handle is the SFTP File Handle β the one you got handed back by libssh2_sftp_open_ex(3). π
buffer is a pointer to a pre-allocated buffer, and it needs to be at least
buffer_maxlen bytes big, because that's where the data's getting read into. no negotiating on that one, she needs the room. π«Ά
So what does it do? It reads a block of data from an LIBSSH2_SFTP_HANDLE. This method is modelled after the POSIX read(2) function and uses the same calling semantics β literally the same energy, just SFTP-flavoured. π
Here's the tea though: libssh2_sftp_read(3) will attempt to read as much as possible, however it may not fill all of buffer if the file pointer reaches the end, or if further reads would cause the socket to block. so like, don't come for her if you don't get a full buffer back, she's doing her best. π
β¨ RETURN VALUE β¨
She returns the number of bytes actually populated into buffer. π
Or, negative on failure. π
Specifically, it returns LIBSSH2_ERROR_EAGAIN when it would otherwise block. And this is the important bit bestie: while LIBSSH2_ERROR_EAGAIN is a negative number, it is not really a failure per se. it's giving "not right now, try again later", not "everything is on fire". β
β¨ ERRORS β¨
LIBSSH2_ERROR_ALLOCβ an internal memory allocation call failed. the allocator said no. πLIBSSH2_ERROR_SOCKET_SENDβ unable to send data on socket. the socket ghosted us. π»LIBSSH2_ERROR_SOCKET_TIMEOUTβ (yes, that's it, that's the whole description in the original too. she's mysterious like that.) β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. π©
β¨ SEE ALSO β¨
(yes she references herself in SEE ALSO. main character energy, we respect it. π)
and that's the whole page bestie!! π this one's from libssh2 0.15, dated 1 Jun 2007 β vintage, but she still ate. πβ¨π¦ periodt.
π¦ 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