3 # $Id: echo.ruby,v 1.1.1.1 2004-05-19 18:09:37 bfulgham Exp $
4 # http://www.bagley.org/~doug/shootout/
8 DATA = "Hello there sailor\n"
10 def echo_client(n
, port
)
11 sock
= TCPsocket
.open('127.0.0.1', port
)
16 raise sprintf("client: \"%s\" \"%s\"", DATA, ans
)
24 ssock
= TCPserver
.open('127.0.0.1', 0)
30 while str
= csock
.gets
34 printf
"server processed %d bytes\n", n
41 echo_server(Integer(ARGV.shift
|| 1))