summaryrefslogtreecommitdiff
path: root/cli/tests/testdata/echo_server.ts
blob: 658b07374e49fd94caef29bb304af177ea72475f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
import { copy } from "../../../test_util/std/streams/copy.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();
  },
);