The following ruby snippet (adapter from an example in 'Programming Ruby') does just that:
require 'socket'
port = ARGV[0] || 80
server = TCPServer.new('localhost', port )
while( session = server.accept)
while !session.eof?
puts session.gets
end
end
Probably cooler would be if it took everything on
STDIN
and echo-ed it back to the socket as well.Update: Thanks pooja. I couldn't think of netcat at the time but that does exactly what I want. I'm such an idiot for not remembering.
No comments:
Post a Comment