pub(crate) fn tcp_pre_connect(
addr: &SocketAddr,
options: &TcpConnectOptions,
) -> Result<Socket>Expand description
Initialize a TCP socket in preparation for a connect().
The socket will be non-blocking, and the socket handle will be close-on-exec/non-inheritable. Other socket options may also be set depending on the socket type and platform.
This returns a socket without any connect() call. The caller MUST:
- connect() the socket.
- Wait for the socket to become writable using whatever mechanism is available with the current runtime.
- Check
SO_ERRORfor errors.
Historically we relied on the runtime to create and connect the socket, but we need some specific socket options set, and not all runtimes will behave the same. It’s better for us to create the socket with the options we need and with consistent behaviour across all runtimes.