libssh2

Форк
0
/
libssh2_sftp_write.3 
73 строки · 3.0 Кб
1
.\" Copyright (C) The libssh2 project and its contributors.
2
.\" SPDX-License-Identifier: BSD-3-Clause
3
.TH libssh2_sftp_write 3 "1 Jun 2007" "libssh2 0.15" "libssh2"
4
.SH NAME
5
libssh2_sftp_write - write SFTP data
6
.SH SYNOPSIS
7
.nf
8
#include <libssh2.h>
9
#include <libssh2_sftp.h>
10

11
ssize_t
12
libssh2_sftp_write(LIBSSH2_SFTP_HANDLE *handle,
13
                   const char *buffer,
14
                   size_t count);
15
.fi
16
.SH DESCRIPTION
17
\fBlibssh2_sftp_write(3)\fP writes a block of data to the SFTP server. This
18
method is modeled after the POSIX write() function and uses the same calling
19
semantics.
20

21
\fIhandle\fP - SFTP file handle as returned by \fIlibssh2_sftp_open_ex(3)\fP.
22

23
\fIbuffer\fP - points to the data to send off.
24

25
\fIcount\fP - Number of bytes from 'buffer' to write. Note that it may not be
26
possible to write all bytes as requested.
27

28
\fIlibssh2_sftp_handle(3)\fP will use as much as possible of the buffer and
29
put it into a single SFTP protocol packet. This means that to get maximum
30
performance when sending larger files, you should try to always pass in at
31
least 32K of data to this function.
32
.SH WRITE AHEAD
33
Starting in libssh2 version 1.2.8, the default behavior of libssh2 is to
34
create several smaller outgoing packets for all data you pass to this function
35
and it will return a positive number as soon as the first packet is
36
acknowledged from the server.
37

38
This has the effect that sometimes more data has been sent off but is not acked
39
yet when this function returns, and when this function is subsequently called
40
again to write more data, libssh2 will immediately figure out that the data is
41
already received remotely.
42

43
In most normal situation this should not cause any problems, but it should be
44
noted that if you have once called libssh2_sftp_write() with data and it returns
45
short, you MUST still assume that the rest of the data might have been cached so
46
you need to make sure you do not alter that data and think that the version you
47
have in your next function invoke will be detected or used.
48

49
The reason for this funny behavior is that SFTP can only send 32K data in each
50
packet and it gets all packets acked individually. This means we cannot use a
51
simple serial approach if we want to reach high performance even on high
52
latency connections. And we want that.
53
.SH RETURN VALUE
54
Actual number of bytes written or negative on failure.
55

56
If used in non-blocking mode, it returns LIBSSH2_ERROR_EAGAIN when it would
57
otherwise block. While LIBSSH2_ERROR_EAGAIN is a negative number, it is not
58
really a failure per se.
59

60
If this function returns 0 (zero) it should not be considered an error, but
61
that there was no error but yet no payload data got sent to the other end.
62
.SH ERRORS
63
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
64

65
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
66

67
\fILIBSSH2_ERROR_SOCKET_TIMEOUT\fP -
68

69
\fILIBSSH2_ERROR_SFTP_PROTOCOL\fP - An invalid SFTP protocol response was
70
received on the socket, or an SFTP operation caused an errorcode to
71
be returned by the server.
72
.SH SEE ALSO
73
.BR libssh2_sftp_open_ex(3)
74

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.