Crate tcp_stream[−][src]
Expand description
mio’s TCP stream on steroids
tcp-stream is a library aiming at providing TLS and futures/tokio support to mio’s TcpStream without forcibly using tokio-reactor
Examples
To connect to a remote server:
use tcp_stream::{HandshakeError, TcpStream, TLSConfig};
use std::io::{self, Read, Write};
fn main() {
let mut stream = TcpStream::connect("google.com:443").unwrap();
while !stream.is_connected() {
if stream.try_connect().unwrap() {
break;
}
}
let mut stream = stream.into_tls("google.com", TLSConfig::default());
while let Err(HandshakeError::WouldBlock(mid_handshake)) = stream {
stream = mid_handshake.handshake();
}
let mut stream = stream.unwrap();
while let Err(err) = stream.write_all(b"GET / HTTP/1.0\r\n\r\n") {
if err.kind() != io::ErrorKind::WouldBlock {
panic!("error: {:?}", err);
}
}
stream.flush().unwrap();
let mut res = vec![];
while let Err(err) = stream.read_to_end(&mut res) {
if err.kind() != io::ErrorKind::WouldBlock {
panic!("stream error: {:?}", err);
}
}
println!("{}", String::from_utf8_lossy(&res));
}
Structs
Holds PKCS#12 DER-encoded identity and decryption password
Reexport native-tls’s TlsConnector
Reexport openssl’s TlsConnector
Reexport openssl’s TlsConnector
Holds PKCS#12 DER-encoded identity and decryption password
Holds extra TLS configuration
Reexport rustls-connector’s TlsConnector
Reexport rustls-connector’s TlsConnector
Holds extra TLS configuration
Enums
An error returned while performing the handshake
A TLS stream which has been interrupted during the handshake
Wrapper around plain or TLS TCP streams
Type Definitions
Holds either the TLS TcpStream result or the current handshake state
A HandshakeError from native-tls
A MidHandshakeTlsStream from native-tls
A TcpStream wrapped by native-tls
An ErrorStack from openssl
A HandshakeError from openssl
A MidHandshakeTlsStream from openssl
A TcpStream wrapped by openssl
A HandshakeError from rustls_connector
A MidHandshakeTlsStream from rustls_connector
A TcpStream wrapped by rustls