1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-23 15:16:54 -05:00
denoland-deno/cli/tests/testdata/echo_server.ts

13 lines
401 B
TypeScript
Raw Normal View History

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) });
2018-10-11 16:55:22 -04:00
console.log("listening on", addr);
listener.accept().then(
async (conn) => {
console.log("received bytes:", await copy(conn, conn));
conn.close();
listener.close();
},
);