Skip to content

Commit 1849323

Browse files
authored
Update index.bs
1 parent 226f2fb commit 1849323

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

index.bs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ The connect method is the primary mechanism for creating a [=socket=] instance.
5151

5252
<h3 id="binding-object-concept">Binding Object</h3>
5353

54+
<p class="note">A [=binding object=] in this context is essentially just an object that exposes the a [=connect=] method conformant with this specification. It is anticipated that a runtime may have any number of such objects. This is an area where there is still active discussion on how this should be defined.</p>
55+
5456
The <dfn export>binding object</dfn> defines extra socket `connect` options. The options it contains can modify the
5557
behaviour of the `connect` invoked on it. Some of the options it can define:
5658

@@ -63,7 +65,7 @@ The binding object is the primary mechanism for runtimes to introduce unique beh
6365

6466
<pre highlight="js">
6567
const tls_socket = new TLSSocket({ key: '...', cert: '...' });
66-
tls_socket.connect();
68+
tls_socket.connect("example.com:1234");
6769
</pre>
6870

6971
Additionally, the binding object does not necessarily have to be an instance of a class, nor does it even have to be JavaScript. It can be any mechanism that exposes the {{connect()}} method. Cloudflare achieves this through [environment bindings](https://developers.cloudflare.com/workers/configuration/bindings/).
@@ -145,9 +147,7 @@ The {{readable}} attribute is a {{ReadableStream}} which receives data from the
145147
</pre>
146148
</div>
147149

148-
The ReadableStream operates in non-byte mode, that is the `type` parameter to the
149-
ReadableStream constructor is not set.
150-
This means the stream's controller is {{ReadableStreamDefaultController}}.
150+
The ReadableStream currently is defined to operate in byte mode, that is the `type` parameter to the ReadableStream constructor is set to `'bytes'`. This means the stream's controller is {{ReadableByteStreamDController}}.
151151

152152
<h4 id="writable-attribute">writable</h4>
153153

@@ -253,6 +253,8 @@ The method must fail with an [=SocketError=] if:
253253

254254
<h3 id="socket-error">SocketError</h3>
255255

256+
<p class="note">Arguably, this should be a type of {{DOMException}} rather than {{TypeError}}. More discussion is necessary on the form and structure of socket-related errors.</p>
257+
256258
<dfn export>SocketError</dfn> is an instance of {{TypeError}}. The error message should start with `"SocketError: "`.
257259

258260
<div class="example">
@@ -299,11 +301,11 @@ The {{connect()}} method performs the following steps:
299301
<li>The created {{Socket}} instance is returned immediately in a <i>pending</i> state.</li>
300302
<li>A connection is established to the specified {{SocketAddress}} asynchronously.</li>
301303
<li>Once the connection is established, set |info| to a new {{SocketInfo}}, and [=Resolve=] |opened| with |info|. For a socket using secure transport, the connection is considered to be established once the secure handshake has been completed.</li>
302-
<li>If the connection fails for any reason, the socket's {{closed}} and {{opened}} promises are rejected with a [=SocketError=] describing why the connection failed.</li>
303-
<li>The instance's {{ReadableStream}} and {{WritableStream}} streams can be used immediately.</li>
304+
<li>If the connection fails for any reason, set |error| to a new [=SocketError=] and reject the socket's {{closed}} and {{opened}} promises with |error|. Also, the {{readable}} is canceled with |error| and the {{writable}} is aborted with |error|.</li>
305+
<li>The instance's {{ReadableStream}} and {{WritableStream}} streams can be used immediately but may not actually transmit or receive data until the socket is fully opened.</li>
304306
</ol>
305307

306-
At any point during the creation of the {{Socket}} instance, `connect` may throw a [=SocketError=]. One case where this can happen is if the input address is incorrectly formatted. Errors which occur asynchronously (after the socket instance has been returned) must reject the socket's {{closed}} promise.
308+
At any point during the creation of the {{Socket}} instance, `connect` may throw a [=SocketError=]. One case where this can happen is if the input address is incorrectly formatted.
307309

308310
<div class="note">
309311
The implementation may consider blocking connections to certain hostname/port combinations which can pose a threat of abuse or security vulnerability.

0 commit comments

Comments
 (0)