Function deltachat::net::connect_tcp

source ·
pub(crate) async fn connect_tcp(
    context: &Context,
    host: &str,
    port: u16,
    timeout_val: Duration,
    load_cache: bool
) -> Result<Pin<Box<TimeoutStream<TcpStream>>>>
Expand description

Returns a TCP connection stream with read/write timeouts set and Nagle’s algorithm disabled with TCP_NODELAY.

TCP_NODELAY ensures writing to the stream always results in immediate sending of the packet to the network, which is important to reduce the latency of interactive protocols such as IMAP.

If load_cache is true, may use cached DNS results. Because the cache may be poisoned with incorrect results by networks hijacking DNS requests, this option should only be used when connection is authenticated, for example using TLS. If TLS is not used or invalid TLS certificates are allowed, this option should be disabled.