diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2019-10-08 00:05:25 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-10-07 18:05:25 -0400 |
commit | 910afdb668d269109b6aec72cea28d20923f2a85 (patch) | |
tree | 66b851bf6c0c98c2f4c201f7457e611445cc0fb7 | |
parent | 96fe2d10a4da0521b7cd72d90fd42121f9311978 (diff) |
fix: Update echo_server to new listen API (denoland/deno_std#625)
Original: https://github.com/denoland/deno_std/commit/287fbb5deca0017202cffef42c97aeee99ef7bee
-rw-r--r-- | examples/echo_server.ts | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/examples/echo_server.ts b/examples/echo_server.ts index 970df4f8d..3bed1bca2 100644 --- a/examples/echo_server.ts +++ b/examples/echo_server.ts @@ -1,12 +1,9 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -const { listen, copy } = Deno; - -(async (): Promise<void> => { - const addr = "0.0.0.0:8080"; - const listener = listen("tcp", addr); - console.log("listening on", addr); - while (true) { - const conn = await listener.accept(); - copy(conn, conn); - } -})(); +const hostname = "0.0.0.0"; +const port = 8080; +const listener = Deno.listen({ hostname, port }); +console.log(`Listening on ${hostname}:${port}`); +while (true) { + const conn = await listener.accept(); + Deno.copy(conn, conn); +} |