tls.socket
local s = tls.socket.new(ip.tcp.dial('www.example.com:https'))
s:client_handshake()
s = http.socket.new(s)
local req = http.request.new()
local res = http.response.new()
req.headers.host = 'www.example.com'
s:write_request(req)
s:read_response(res)
Functions
new(sock: ip.tcp.socket[, tls_ctx: tls.context]) → tls.socket
Constructor.
If tls_ctx
is not provided, a per-VM — generated on first use — default one
will be used.
client_handshake(self)
Perform the TLS client handshake and suspend current fiber until operation finishes.
server_handshake(self)
Perform the TLS server handshake and suspend current fiber until operation finishes.
read_some(self, buffer: byte_span) → integer
Read data from the stream socket and blocks current fiber until it completes or errs.
Returns the number of bytes read.
write_some(self, buffer: byte_span) → integer
Write data to the stream socket and blocks current fiber until it completes or errs.
Returns the number of bytes written.