mirror of
https://github.com/denoland/deno
synced 2024-11-05 18:45:24 +00:00
12 lines
347 B
TypeScript
12 lines
347 B
TypeScript
const { args, listen, copy } = Deno;
|
|
const addr = args[1] || "0.0.0.0:4544";
|
|
const [hostname, port] = addr.split(":");
|
|
const listener = listen({ hostname, port: Number(port) });
|
|
console.log("listening on", addr);
|
|
listener.accept().then(
|
|
async (conn): Promise<void> => {
|
|
await copy(conn, conn);
|
|
conn.close();
|
|
listener.close();
|
|
}
|
|
);
|