Skip to content

Commit 77f876a

Browse files
author
Ethan Arrowood
committed
add more details and example to the binding section
1 parent 4ad25e1 commit 77f876a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

index.bs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,13 @@ The <dfn>binding object</dfn> defines socket `connect` options. The options it c
305305
behaviour of the `connect` invoked on it. Some of the options it can define:
306306

307307
* TLS settings
308-
* The HTTP proxy to use for the socket connection
308+
* The HTTP proxy to use for the socket connection
309+
310+
The binding object is the primary mechanism for runtimes to introduce unique behavior for the {{connect()}} method. For example, in order to support more TLS settings, a runtime may introduce a `TLSSocket` interface that extends from {{Socket}}. Thus, the binded {{connect()}} method could then utilize additional properties and configuration values that are controlled by the new `TLSSocket` interface.
311+
312+
```js
313+
const tls_socket = new TLSSocket({ key: '...', cert: '...' });
314+
tls_socket.connect(); // works just like the `connect()` specified in this document, but also utilizes the configuration passed to `TLSSocket`.
315+
```
316+
317+
Additionally, the binding object does not necessarily have to be an instance of a class. It can be any object that has the {{connect()}} method. Cloudflare achieves this through [environment bindings](https://developers.cloudflare.com/workers/configuration/bindings/).

0 commit comments

Comments
 (0)