Skip to content

Commit e6de68b

Browse files
authored
Merge pull request #6 from wintercg/expand-binding-object-section
2 parents 84c8eb0 + 77f876a commit e6de68b

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
@@ -315,4 +315,13 @@ The <dfn>binding object</dfn> defines socket `connect` options. The options it c
315315
behaviour of the `connect` invoked on it. Some of the options it can define:
316316

317317
* TLS settings
318-
* The HTTP proxy to use for the socket connection
318+
* The HTTP proxy to use for the socket connection
319+
320+
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.
321+
322+
```js
323+
const tls_socket = new TLSSocket({ key: '...', cert: '...' });
324+
tls_socket.connect(); // works just like the `connect()` specified in this document, but also utilizes the configuration passed to `TLSSocket`.
325+
```
326+
327+
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)