16 lines
312 B
Ruby
16 lines
312 B
Ruby
require 'socket'
|
|
|
|
server = TCPServer.new('0.0.0.0', 24000)
|
|
loop do
|
|
Thread.start(server.accept) do |client|
|
|
if (ping = client.gets) =~ /PING/
|
|
puts 'server: RECV PING'
|
|
client.puts("PONG\n")
|
|
else
|
|
puts "server: RECV #{ping}"
|
|
client.puts("NOPE\n")
|
|
end
|
|
client.close
|
|
end
|
|
end
|