summaryrefslogtreecommitdiff
path: root/js/net.ts
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2018-10-15 07:29:50 +1100
committerRyan Dahl <ry@tinyclouds.org>2018-10-14 17:38:23 -0400
commit10a97679ac80b4304c75d33cbc59c5736d11deb1 (patch)
treeb51b9183ed251f61373069e5c4d35e39603bedb2 /js/net.ts
parent1840a1971317f5b8fc6e322b3a414b7f8a593c88 (diff)
Align JSDoc to style guide.
Diffstat (limited to 'js/net.ts')
-rw-r--r--js/net.ts60
1 files changed, 35 insertions, 25 deletions
diff --git a/js/net.ts b/js/net.ts
index da8a0303e..4a0625c4d 100644
--- a/js/net.ts
+++ b/js/net.ts
@@ -16,14 +16,15 @@ export type Addr = string;
/** A Listener is a generic network listener for stream-oriented protocols. */
export interface Listener {
- /** accept() waits for and returns the next connection to the Listener. */
+ /** Waits for and resolves to the next connection to the `Listener`. */
accept(): Promise<Conn>;
- /** Close closes the listener.
- * Any pending accept promises will be rejected with errors.
+ /** Close closes the listener. Any pending accept promises will be rejected
+ * with errors.
*/
close(): void;
+ /** Return the address of the `Listener`. */
addr(): Addr;
}
@@ -53,9 +54,17 @@ class ListenerImpl implements Listener {
}
export interface Conn extends Reader, Writer, Closer {
+ /** The local address of the connection. */
localAddr: string;
+ /** The remote address of the connection. */
remoteAddr: string;
+ /** Shuts down (`shutdown(2)`) the reading side of the TCP connection. Most
+ * callers should just use `close()`.
+ */
closeRead(): void;
+ /** Shuts down (`shutdown(2)`) the writing side of the TCP connection. Most
+ * callers should just use `close()`.
+ */
closeWrite(): void;
}
@@ -113,18 +122,18 @@ function shutdown(rid: number, how: ShutdownMode) {
/** Listen announces on the local network address.
*
- * The network must be "tcp", "tcp4", "tcp6", "unix" or "unixpacket".
+ * The network must be `tcp`, `tcp4`, `tcp6`, `unix` or `unixpacket`.
*
* For TCP networks, if the host in the address parameter is empty or a literal
- * unspecified IP address, Listen listens on all available unicast and anycast
- * IP addresses of the local system. To only use IPv4, use network "tcp4". The
- * address can use a host name, but this is not recommended, because it will
- * create a listener for at most one of the host's IP addresses. If the port in
- * the address parameter is empty or "0", as in "127.0.0.1:" or "[::1]:0", a
- * port number is automatically chosen. The Addr method of Listener can be used
- * to discover the chosen port.
+ * unspecified IP address, `listen()` listens on all available unicast and
+ * anycast IP addresses of the local system. To only use IPv4, use network
+ * `tcp4`. The address can use a host name, but this is not recommended,
+ * because it will create a listener for at most one of the host's IP
+ * addresses. If the port in the address parameter is empty or `0`, as in
+ * `127.0.0.1:` or `[::1]:0`, a port number is automatically chosen. The
+ * `addr()` method of `Listener` can be used to discover the chosen port.
*
- * See dial() for a description of the network and address parameters.
+ * See `dial()` for a description of the network and address parameters.
*/
export function listen(network: Network, address: string): Listener {
const builder = new flatbuffers.Builder();
@@ -144,16 +153,17 @@ export function listen(network: Network, address: string): Listener {
/** Dial connects to the address on the named network.
*
- * Supported networks are only "tcp" currently.
- * TODO: "tcp4" (IPv4-only), "tcp6" (IPv6-only), "udp", "udp4"
- * (IPv4-only), "udp6" (IPv6-only), "ip", "ip4" (IPv4-only), "ip6" (IPv6-only),
- * "unix", "unixgram" and "unixpacket".
+ * Supported networks are only `tcp` currently.
+ *
+ * TODO: `tcp4` (IPv4-only), `tcp6` (IPv6-only), `udp`, `udp4` (IPv4-only),
+ * `udp6` (IPv6-only), `ip`, `ip4` (IPv4-only), `ip6` (IPv6-only), `unix`,
+ * `unixgram` and `unixpacket`.
*
- * For TCP and UDP networks, the address has the form "host:port". The host must
+ * For TCP and UDP networks, the address has the form `host:port`. The host must
* be a literal IP address, or a host name that can be resolved to IP addresses.
* The port must be a literal port number or a service name. If the host is a
* literal IPv6 address it must be enclosed in square brackets, as in
- * "[2001:db8::1]:80" or "[fe80::1%zone]:80". The zone specifies the scope of
+ * `[2001:db8::1]:80` or `[fe80::1%zone]:80`. The zone specifies the scope of
* the literal IPv6 address as defined in RFC 4007. The functions JoinHostPort
* and SplitHostPort manipulate a pair of host and port in this form. When using
* TCP, and the host resolves to multiple IP addresses, Dial will try each IP
@@ -161,12 +171,12 @@ export function listen(network: Network, address: string): Listener {
*
* Examples:
*
- * dial("tcp", "golang.org:http")
- * dial("tcp", "192.0.2.1:http")
- * dial("tcp", "198.51.100.1:80")
- * dial("udp", "[2001:db8::1]:domain")
- * dial("udp", "[fe80::1%lo0]:53")
- * dial("tcp", ":80")
+ * dial("tcp", "golang.org:http")
+ * dial("tcp", "192.0.2.1:http")
+ * dial("tcp", "198.51.100.1:80")
+ * dial("udp", "[2001:db8::1]:domain")
+ * dial("udp", "[fe80::1%lo0]:53")
+ * dial("tcp", ":80")
*/
export async function dial(network: Network, address: string): Promise<Conn> {
const builder = new flatbuffers.Builder();
@@ -184,7 +194,7 @@ export async function dial(network: Network, address: string): Promise<Conn> {
return new ConnImpl(res.rid(), res.remoteAddr()!, res.localAddr()!);
}
-// Unused but reserved op.
+/** **RESERVED** */
export async function connect(
network: Network,
address: string