1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 16:49:18 -05:00
denoland-deno/cli/tests/echo_server.ts
2020-07-14 15:24:17 -04:00

11 lines
326 B
TypeScript

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> => {
await Deno.copy(conn, conn);
conn.close();
listener.close();
},
);