File: echo.lua

package info (click to toggle)
nmap 7.98%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 45,872 kB
  • sloc: cpp: 61,855; ansic: 31,545; python: 17,238; sh: 15,622; xml: 11,564; perl: 2,650; makefile: 966; java: 45; objc: 45
file content (16 lines) | stat: -rw-r--r-- 335 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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