diff --git a/examples/echo_server.ts b/examples/echo_server.ts index 970df4f8d7..3bed1bca2e 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 => { - 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); +}