Skip to content

Commit

Permalink
fix: Update echo_server to new listen API (#625)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju authored and ry committed Oct 7, 2019
1 parent c3fe858 commit 287fbb5
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions examples/echo_server.ts
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 287fbb5

Please sign in to comment.