1SSL_write(3)                        OpenSSL                       SSL_write(3)
2
3
4

NAME

6       SSL_write - write bytes to a TLS/SSL connection.
7

SYNOPSIS

9        #include <openssl/ssl.h>
10
11        int SSL_write(SSL *ssl, const void *buf, int num);
12

DESCRIPTION

14       SSL_write() writes num bytes from the buffer buf into the specified ssl
15       connection.
16

NOTES

18       If necessary, SSL_write() will negotiate a TLS/SSL session, if not
19       already explicitly performed by SSL_connect(3) or SSL_accept(3). If the
20       peer requests a re-negotiation, it will be performed transparently
21       during the SSL_write() operation. The behaviour of SSL_write() depends
22       on the underlying BIO.
23
24       For the transparent negotiation to succeed, the ssl must have been
25       initialized to client or server mode. This is being done by calling
26       SSL_set_connect_state(3) or SSL_set_accept_state() before the first
27       call to an SSL_read(3) or SSL_write() function.
28
29       If the underlying BIO is blocking, SSL_write() will only return, once
30       the write operation has been finished or an error occurred, except when
31       a renegotiation take place, in which case a SSL_ERROR_WANT_READ may
32       occur.  This behaviour can be controlled with the SSL_MODE_AUTO_RETRY
33       flag of the SSL_CTX_set_mode(3) call.
34
35       If the underlying BIO is non-blocking, SSL_write() will also return,
36       when the underlying BIO could not satisfy the needs of SSL_write() to
37       continue the operation. In this case a call to SSL_get_error(3) with
38       the return value of SSL_write() will yield SSL_ERROR_WANT_READ or
39       SSL_ERROR_WANT_WRITE. As at any time a re-negotiation is possible, a
40       call to SSL_write() can also cause read operations! The calling process
41       then must repeat the call after taking appropriate action to satisfy
42       the needs of SSL_write(). The action depends on the underlying BIO.
43       When using a non-blocking socket, nothing is to be done, but select()
44       can be used to check for the required condition. When using a buffering
45       BIO, like a BIO pair, data must be written into or retrieved out of the
46       BIO before being able to continue.
47
48       SSL_write() will only return with success, when the complete contents
49       of buf of length num has been written. This default behaviour can be
50       changed with the SSL_MODE_ENABLE_PARTIAL_WRITE option of
51       SSL_CTX_set_mode(3). When this flag is set, SSL_write() will also
52       return with success, when a partial write has been successfully
53       completed. In this case the SSL_write() operation is considered
54       completed. The bytes are sent and a new SSL_write() operation with a
55       new buffer (with the already sent bytes removed) must be started.  A
56       partial write is performed with the size of a message block, which is
57       16kB for SSLv3/TLSv1.
58

WARNING

60       When an SSL_write() operation has to be repeated because of
61       SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE, it must be repeated with
62       the same arguments.
63
64       When calling SSL_write() with num=0 bytes to be sent the behaviour is
65       undefined.
66

RETURN VALUES

68       The following return values can occur:
69
70       >0  The write operation was successful, the return value is the number
71           of bytes actually written to the TLS/SSL connection.
72
73       0   The write operation was not successful. Probably the underlying
74           connection was closed. Call SSL_get_error() with the return value
75           ret to find out, whether an error occurred or the connection was
76           shut down cleanly (SSL_ERROR_ZERO_RETURN).
77
78           SSLv2 (deprecated) does not support a shutdown alert protocol, so
79           it can only be detected, whether the underlying connection was
80           closed. It cannot be checked, why the closure happened.
81
82       <0  The write operation was not successful, because either an error
83           occurred or action must be taken by the calling process. Call
84           SSL_get_error() with the return value ret to find out the reason.
85

SEE ALSO

87       SSL_get_error(3), SSL_read(3), SSL_CTX_set_mode(3), SSL_CTX_new(3),
88       SSL_connect(3), SSL_accept(3) SSL_set_connect_state(3), ssl(3), bio(3)
89
90
91
921.0.0e                            2002-07-19                      SSL_write(3)
Impressum