Project

General

Profile

Bug #9753 » simple_server2.rb

ThomasWLynch (Thomas Lynch), 04/17/2014 10:23 AM

 
#!/bin/ruby
=begin

a simple server

=end

require 'socket'

server = UNIXServer.new("test_socket")
session_id=0
while( data_sock = server.accept)
Thread.new(session_id) {|our_session|
puts "server starting session #{our_session}"
while( request = data_sock.gets )
puts request
data_sock.puts "{\"reply\":\"test_interface_to_interface\"}"
end
puts "client closed the connection #{our_session}"
}
session_id += 1
end
server.close
(1-1/5)