1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-28 01:59:06 -05:00
denoland-deno/cli/tests/echo_server.ts
2021-07-12 19:44:42 +02:00

12 lines
408 B
TypeScript

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): Promise<void> => {
console.log("received bytes:", await copy(conn, conn));
conn.close();
listener.close();
},
);