On Mon, Jul 28, 2003 at 08:22:49PM +0900, Xiangrong Fang wrote:
> 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.

Does your other program also bind to localhost, or does it bind to 0.0.0.0
(INADDR_ANY, meaning 'all interfaces')?

Maybe Windows is broken in allowing program A to bind to 127.0.0.1, then
when program B binds to 0.0.0.0 it takes over 127.0.0.1 as well. Just a
guess.

But try changing your Ruby program to:
   server = TCPServer.new('0.0.0.0', port)

Regards,

Brian.