X
Xiangrong Fang
Hi,
I wrote a socket program using ruby under windows, the main loop of this
program is:
begin
server = TCPServer.new('127.0.0.1', port)
rescue Exception => e
puts e.message
exit
end
while session = server.accept do
Thread.new do
Client.new(session).run
end
end
It runs smoothly. However I found a strange problem. If I run another
program (not written in Ruby) using the same port, that program will
take control of the port, and my program is "over-ruled"! However, if
the other program runs first, and then I run my ruby one, the ruby
program print out error message that it can't bind the port.
I don't know why ruby's socket is so polite? Wondering...
I wrote a socket program using ruby under windows, the main loop of this
program is:
begin
server = TCPServer.new('127.0.0.1', port)
rescue Exception => e
puts e.message
exit
end
while session = server.accept do
Thread.new do
Client.new(session).run
end
end
It runs smoothly. However I found a strange problem. If I run another
program (not written in Ruby) using the same port, that program will
take control of the port, and my program is "over-ruled"! However, if
the other program runs first, and then I run my ruby one, the ruby
program print out error message that it can't bind the port.
I don't know why ruby's socket is so polite? Wondering...