summaryrefslogtreecommitdiffstats
path: root/ncat/scripts/echo.lua
diff options
context:
space:
mode:
Diffstat (limited to 'ncat/scripts/echo.lua')
-rw-r--r--ncat/scripts/echo.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/ncat/scripts/echo.lua b/ncat/scripts/echo.lua
new file mode 100644
index 0000000..3bfea90
--- /dev/null
+++ b/ncat/scripts/echo.lua
@@ -0,0 +1,16 @@
+--Emulates the RFC 862 echo service, behaving like Unix's "cat" tool.
+
+while true do
+
+ --We're reading in 1-byte chunks because calls like io.stdin:read(512) would
+ --wait for full 512 bytes of data before continuing.
+ data = io.stdin:read(1)
+
+ if data == nil then
+ break
+ end
+
+ io.stdout:write(data)
+ io.stdout:flush()
+
+end