M
Max Kuffs
Hello,
I would like to write a little TCPServer which communicates with
another ruby program on another computer.
So i tried all with TCPServer. I could connect and it worked, but i
want to execute it in a thread and now the program halts when i open
the server.
i use ruby 1.8 for windows. does this matter in that case?
best regards
Max Kuffs
My source:
require 'socket'
SERVER_PORT = 4772
LISTEN_ON = '0.0.0.0'
srv = Thread.new(){
ss=TCPServer.new LISTEN_ON,SERVER_PORT
con=ss.accept
while !con.eof?
puts con.gets
end
}
while true do
puts "Cycle"
if srv.stop? then
# Restarting Thread if died
puts "Restarting Server Thread!"
srv.run
end
puts "sleeep-----------------------------------------"
sleep 5
end
I would like to write a little TCPServer which communicates with
another ruby program on another computer.
So i tried all with TCPServer. I could connect and it worked, but i
want to execute it in a thread and now the program halts when i open
the server.
i use ruby 1.8 for windows. does this matter in that case?
best regards
Max Kuffs
My source:
require 'socket'
SERVER_PORT = 4772
LISTEN_ON = '0.0.0.0'
srv = Thread.new(){
ss=TCPServer.new LISTEN_ON,SERVER_PORT
con=ss.accept
while !con.eof?
puts con.gets
end
}
while true do
puts "Cycle"
if srv.stop? then
# Restarting Thread if died
puts "Restarting Server Thread!"
srv.run
end
puts "sleeep-----------------------------------------"
sleep 5
end