File: echod.rb

package info (click to toggle)
libwrap-ruby 0.6-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, sarge, squeeze, wheezy
  • size: 76 kB
  • ctags: 32
  • sloc: ansic: 179; ruby: 66; makefile: 45
file content (17 lines) | stat: -rw-r--r-- 272 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/ruby

require "tcpwrap"

serv = TCPServer.open(ARGV.shift || "echo")
tcpd = TCPWrapper.new("echod", serv, true, 30)
loop do
  ns = tcpd.accept
  Thread.start do
    s = ns
    while line = s.gets
      s.print(line)
    end
    s.shutdown
    s.close
  end
end