diff options
author | Kevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com> | 2019-12-29 07:20:23 -0800 |
---|---|---|
committer | Ry Dahl <ry@tinyclouds.org> | 2019-12-29 10:20:23 -0500 |
commit | 176d1ff12e1984593282b58adf54f34f971be837 (patch) | |
tree | c9894f277d3ee8b330aff04ca7227ba60d5ce6c1 /cli/js/net.ts | |
parent | 4d4908dde31316462acae5caec8dfcbbf7a244bd (diff) |
net: expose shutdown() and ShutdownMode (#3558)
Diffstat (limited to 'cli/js/net.ts')
-rw-r--r-- | cli/js/net.ts | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cli/js/net.ts b/cli/js/net.ts index 8109934a4..3f7785f2b 100644 --- a/cli/js/net.ts +++ b/cli/js/net.ts @@ -32,7 +32,7 @@ export interface Listener extends AsyncIterator<Conn> { [Symbol.asyncIterator](): AsyncIterator<Conn>; } -enum ShutdownMode { +export enum ShutdownMode { // See http://man7.org/linux/man-pages/man2/shutdown.2.html // Corresponding to SHUT_RD, SHUT_WR, SHUT_RDWR Read = 0, @@ -40,7 +40,15 @@ enum ShutdownMode { ReadWrite // unused } -function shutdown(rid: number, how: ShutdownMode): void { +/** Shut down socket send and receive operations. + * + * Matches behavior of POSIX shutdown(3). + * + * const listener = Deno.listen({ port: 80 }); + * const conn = await listener.accept(); + * Deno.shutdown(conn.rid, Deno.ShutdownMode.Write); + */ +export function shutdown(rid: number, how: ShutdownMode): void { sendSync(dispatch.OP_SHUTDOWN, { rid, how }); } |