summaryrefslogtreecommitdiff
path: root/cli/tests/echo_server.ts
blob: 84284bea11621c1b98ead9cb1f9100b199cadb68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
import { copy } from "../../test_util/std/io/util.ts";
const addr = Deno.args[0] || "0.0.0.0:4544";
const [hostname, port] = addr.split(":");
const listener = Deno.listen({ hostname, port: Number(port) });
console.log("listening on", addr);
listener.accept().then(
  async (conn) => {
    console.log("received bytes:", await copy(conn, conn));
    conn.close();
    listener.close();
  },
);