1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 07:44:48 -05:00

fix: Update echo_server to new listen API (denoland/deno_std#625)

Original: 287fbb5dec
This commit is contained in:
Bartek Iwańczuk 2019-10-08 00:05:25 +02:00 committed by Ryan Dahl
parent 96fe2d10a4
commit 910afdb668

View file

@ -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);
}