TlsSocketA TLS-encrypted TCP connection, with the same read/write surface as TcpSocket.
connect: speaks TLS from the first byte (certificate checked against the host name); wrap:host: upgrades an existing plaintext TcpSocket in place — the STARTTLS pattern — consuming it. The insecure: variants take a Boolean that, when true, skips certificate validation: local debugging only, the word at the call site is the warning. The do: forms scope the socket to a block, closing it on every exit path.
TlsSocket.connect:'example.com:443' do:{ |sock| sock.writeAll:'GET / HTTP/1.0\r\nHost: example.com\r\n\r\n'.asBytes sock.readAll }
Connect to 'host:port' speaking TLS from the first byte; the host part is also the certificate / SNI name. A failed handshake (or a certificate that doesn't validate) throws a catchable IoError.
Connect with TLS, run the block with the socket, and close it on every exit path (normal, throw, or cancel); answers the block's value.
connect:, with certificate validation skipped when the Boolean is true — for local debugging against self-signed certificates, never production.
The scoped (do:) form of connect:insecure:.
Upgrade an already-connected TcpSocket to TLS in place (the STARTTLS pattern). host: names the certificate / SNI identity — supplied explicitly because the connection may have been made by IP or via a proxy. The TcpSocket is *consumed*: it is left closed whether the handshake succeeds or not.
Upgrade a TcpSocket to TLS, run the block with the TlsSocket, and close it on every exit path; answers the block's value.
wrap:host:, with certificate validation skipped when the Boolean is true (local debugging only).
The scoped (do:) form of wrap:host:insecure:.
A buffered ByteStream that *consumes* this socket: the connection transfers to the stream and the socket is left closed (further ops on it throw). Adds read-ahead, peek:, and delimiter framing (readUntil:) over the raw socket.
Close the socket (idempotent — a second close is a no-op). Further operations throw. Returns nil.
Whether the socket has been closed — including by being consumed into a stream or a TLS upgrade.
Up to n bytes as Bytes — one read, so possibly fewer than asked; empty Bytes means the peer closed (EOF). Parks the task until data arrives. Throws on a closed socket or an I/O error. For buffered or delimiter-framed reading, wrap the socket in byteStream.
Read until the peer closes, answering everything as one Bytes. Only returns once the other side signals EOF — for request/response protocols where the peer keeps the connection open, frame reads with read: or a byteStream instead.
A text StringStream that *consumes* this socket (a byteStream immediately wrapped): readLine / eachLine: / writeln: over the connection, decoding UTF-8.
Write all of the Bytes to the socket — complete or throw, no short writes. Returns nil.