write_nonblock
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180 (0)
- 1_9_3_125 (4)
- 1_9_3_392 (0)
- 2_1_10 (0)
- 2_2_9 (0)
- 2_4_6 (38)
- 2_5_5 (1)
- 2_6_3 (0)
- What's this?
write_nonblock(s)
public
Writes str in the non-blocking manner.
If there are buffered data, it is flushed at first. This may block.
write_nonblock returns number of bytes written to the SSL connection.
When no data can be written without blocking, It raises OpenSSL::SSL::SSLError extended by IO::WaitReadable or IO::WaitWritable.
IO::WaitReadable means SSL needs to read internally. So write_nonblock should be called again after underlying IO is readable.
IO::WaitWritable means SSL needs to write internally. So write_nonblock should be called again after underlying IO is writable.
So OpenSSL::Buffering#write_nonblock needs two rescue clause as follows.
# emulates blocking write. begin
result = ssl.write_nonblock(str)
rescue IO::WaitReadable
IO.select([io]) retry
rescue IO::WaitWritable
IO.select(nil, [io]) retry
end
Note that one reason that write_nonblock read from a underlying IO is the peer requests a new TLS/SSL handshake. See openssl FAQ for more details. http://www.openssl.org/support/faq.html