On this page:
connect

2 Secure Clients🔗ℹ

function

fun ssl.connect(

  ~host: host :: String,

  ~port: port :: network.PortNumber,

  ~context: context :: ssl.Context.Client = ssl.Context.Client(),

  ~alpn_protcols: alpn_protocols :: List.of(Bytes) = []

) :~ values(ssl.Port.Input, ss.Port.Output)

Connects to host at port, similiar to (and building on) network.TCP.connect, but for a secure connection. The context argument along with alpn_protocols configures the connection. By default, context is a secure connection that checks a certificate that host provides as part of the SSL protocol.

If alpn_protocols is not empty, the client attempts to use ALPN to negotiate the connection protocol. Protocols should be listed in order of preference, and each protocol must be a byte string with a length between 1 and 255 (inclusive). See also ssl.Port.selected_alpn.

Closing the resulting output port does not send a shutdown message to the server. See also ssl.Port.from_ports and its ~shutdown_on_close argument.