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