Skip to content

Commit f078957

Browse files
authored
Add SocketInfo, update opened promise
The `opened` promise resolves to a `SocketInfo`. `SocketInfo` provides `remoteAddress` and (optionally) `localAddress`
1 parent 1d42a50 commit f078957

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

index.bs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,18 @@ A basic example of using connect with an echo server.
8989
The {{Socket}} class is an instance of the [=socket=] concept. It should not be instantiated directly (`new Socket()`), but instead created by calling {{connect()}}. A constructor for {{Socket}} is intentionally not specified, and is left to implementors to create.
9090

9191
<pre class="idl">
92+
[Exposed=*]
93+
dictionary SocketInfo {
94+
DOMString remoteAddress = null;
95+
DOMString localAddress = null;
96+
};
97+
9298
[Exposed=*]
9399
interface Socket {
94100
readonly attribute ReadableStream readable;
95101
readonly attribute WritableStream writable;
96102

97-
readonly attribute Promise&lt;undefined> opened;
103+
readonly attribute Promise&lt;SocketInfo> opened;
98104

99105
readonly attribute Promise&lt;undefined> closed;
100106
Promise&lt;undefined> close(optional any reason);
@@ -162,6 +168,11 @@ The {{opened}} attribute is a promise that is resolved when the socket connectio
162168
successfully established, or is rejected if the connection fails. For sockets use secure-transport,
163169
the resolution of the {{opened}} promise indicates the completion of the secure handshake.
164170

171+
The {{opened}} promise resolves a {{SocketInfo}} dictionary that optionally provides details
172+
about the connection that has been established.
173+
174+
By default, the {{opened}} promise is {{marked as handled}}.
175+
165176
<h4 id="closed-attribute">closed</h4>
166177

167178
The {{closed}} attribute is a promise which can be used to keep track of the socket state. It gets resolved under the
@@ -296,7 +307,7 @@ At any point during the creation of the {{Socket}} instance, `connect` may throw
296307
{{secureTransport}} member
297308
</dt>
298309
<dd>
299-
The secure transport mode to use.
310+
The secure transport mode to use.f
300311
<dl>
301312
<dt>{{off}}</dt>
302313
<dd>A connection is established in plain text.</dd>
@@ -321,6 +332,24 @@ At any point during the creation of the {{Socket}} instance, `connect` may throw
321332
</dd>
322333
</dl>
323334

335+
<h3 id="socketinfo-dictionary">`SocketInfo` dictionary</h3>
336+
337+
<d1>
338+
<dt>
339+
{{remoteAddress}} member
340+
</dt>
341+
<dd>
342+
Provides the hostname/port combo of the remote peer the {{Socket}} is connected to, for example `"example.com:443"`.
343+
This value may or may not be the same as the address provided to the {{connect()}} method used to create the {{Socket}}.
344+
</dd>
345+
<dt>
346+
{{localAddress}} member
347+
</dt>
348+
<dd>
349+
Optionally provides the hostname/port combo of the local network endpoint, for example `"localhost:12345"`.
350+
</dd>
351+
</d1>
352+
324353
<h3 id="anysocketaddress-type">`AnySocketAddress` type</h3>
325354

326355
<dl>

0 commit comments

Comments
 (0)