data TlsListener
A listening TLS socket: accept takes a TCP connection and runs the server handshake.
Example:
use std.net { TlsListener, TlsConfig, SocketAddr }
fn serve(addr: SocketAddr) -> () | NetError io, net {
let l = TlsListener.bind(addr, TlsConfig{ cert: "server.pem", key: "server.key" })?
defer l.close()?
let s = l.accept()?
defer s.close()?
s.writeText("hello\n")?
}@must_close
pub(api) data TlsListenerThread safety. `accept` may be called by one task at a time.
Since. 1.0.0-beta
Fields
pub(api) local: SocketAddr | The address the socket listens on. |
Methods
bind | (addr: SocketAddr, cfg: TlsConfig, backlog: i64) -> TlsListener | NetError netBinds, listens and loads the certificate from cfg (port 0 picks a free port |
accept | (timeout: Duration?) -> TlsStream | NetError netWaits for the next connection and completes its TLS handshake. |
acceptTcp | (timeout: Duration?) -> TcpStream | NetError netAccepts the next TCP connection without TLS; finish it with handshake. |
handshake | (tcp: TcpStream, timeout: Duration?) -> TlsStream | NetError netRuns the server handshake on a connection from acceptTcp (which it consumes). |
close | () -> () | NetError netCloses the listening socket. |
Defined in: std/net/tls.oxl:469