[][src]Crate tcp_stream

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};

use std::io::{self, Read, Write};

fn main() {
    let stream = TcpStream::connect("google.com:443").unwrap();
    let mut stream = stream.into_tls("google.com");

    while let Err(HandshakeError::WouldBlock(mid_handshake)) = stream {
        stream = mid_handshake.handshake();
    }

    let mut stream = stream.unwrap();

    stream.write_all(b"GET / HTTP/1.0\r\n\r\n").unwrap();
    stream.flush().unwrap();
    let mut res = vec![];
    while let Err(err) = stream.read_to_end(&mut res) {
        if err.kind() != io::ErrorKind::WouldBlock {
            eprintln!("stream error: {:?}", err);
            break;
        }
    }
    println!("{}", String::from_utf8_lossy(&res));
}

Structs

NativeTlsConnector

A builder for client-side TLS connections.

OpenSslConnector

A type which wraps client-side streams in a TLS session.

OpenSslMethod

A type specifying the kind of protocol an SslContext will speak.

RustlsConnector

The connector

Enums

HandshakeError

An error returned while performing the handshake

MidHandshakeTlsStream

A TLS stream which has been interrupted during the handshake

TcpStream

Wrapper around plain or TLS TCP streams

Type Definitions

NativeTlsHandshakeError

A HandshakeError from native-tls

NativeTlsMidHandshakeTlsStream

A MidHandshakeTlsStream from native-tls

NativeTlsStream

A TcpStream wrapped by native-tls

OpenSslHandshakeError

A HandshakeError from openssl

OpenSslMidHandshakeTlsStream

A MidHandshakeTlsStream from openssl

OpenSslStream

A TcpStream wrapped by openssl

RustlsHandshakeError

A HandshakeError from rustls_connector

RustlsMidHandshakeTlsStream

A MidHandshakeTlsStream from rustls_connector

RustlsStream

A TcpStream wrapped by rustls