You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Runtime Environment/Socket.md
+17-4Lines changed: 17 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -112,23 +112,36 @@ Attempts to add the TLS crypto layer to the socket, making the transport layer a
112
112
#### Parameters (Client)
113
113
1. The socket instance.
114
114
2. The host name of the intended remote. This may be the same as what was passed to `socket.connect`. This name must be on the certificate that the remote will send.
115
+
3. An optional table of options.
115
116
#### Parameters (Server)
116
117
1. The socket instance.
117
118
2. An array of tables describing available certificates. Each certificate needs a `chain` and `private_key` field, which should be a string containing valid PEM. The `private_key` must be RSA.
119
+
3. An optional table of options.
120
+
#### Options
121
+
-`alpn` — An array of protocol names to negotiate via ALPN. On success, the selected protocol is returned as a second value.
122
+
-`early_data` — Data to send immediately after the TLS handshake begins. Client only.
118
123
#### Returns
119
-
True on success. On failure, returns false and the socket is closed. If the socket is already using TLS, returns nil.
124
+
`true` on success and, if ALPN is used, the selected protocol. On failure, returns `false` and the socket is closed. If the socket is already using TLS, returns `nil`.
120
125
#### Multitasking
121
126
If called inside of a coroutine, this function yields. Otherwise, it blocks.
122
-
```pluto norun title="Client Example"
127
+
```pluto norun title="Client Example (Early Data)"
123
128
local socket = require "pluto:socket"
124
129
125
130
local s = socket.connect("pluto-lang.org", 443)
126
-
assert(s:starttls("pluto-lang.org"), "Failed to establish secure connection.")
0 commit comments