summaryrefslogtreecommitdiff
path: root/examples/echo_server.ts
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-12-19 13:50:48 -0500
committerGitHub <noreply@github.com>2018-12-19 13:50:48 -0500
commit3542f2de0cecdbcf07d3bea3de6439e6a87376df (patch)
tree53c39ae3456fa8d6a360485378e8d82949b09e9a /examples/echo_server.ts
parentecde6a4c503584aa712f40e70c8e1aa78959e110 (diff)
Add examples/ directory (denoland/deno_std#28)
Previously https://github.com/denoland/deno_examples Original: https://github.com/denoland/deno_std/commit/14be9a0e82d1b54d5b0f04291d9154d1d7da29f7
Diffstat (limited to 'examples/echo_server.ts')
-rw-r--r--examples/echo_server.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/examples/echo_server.ts b/examples/echo_server.ts
new file mode 100644
index 000000000..1d5b287db
--- /dev/null
+++ b/examples/echo_server.ts
@@ -0,0 +1,11 @@
+import { listen, copy } from "deno";
+
+(async () => {
+ const addr = "0.0.0.0:8080";
+ const listener = listen("tcp", addr);
+ console.log("listening on", addr);
+ while (true) {
+ const conn = await listener.accept();
+ copy(conn, conn);
+ }
+})();