Shea Martin wrote:
> I want to listen for connections for 2 seconds, then timeout.  Do I have 
>  to use the Timeout module?
> 
> ~S


My situation is more like this:

<code>
Thread.new do

begin
   l_exit_status = false

   l_listener = TCPServer.new( HOST, p_port )
   l_socket = false

   Timeout.timeout( 2 ) do
     l_socket = l_listener.accept
   end #timeout

   #use socket
   l_socket.put "send you requested data"

   l_exit_status = true

rescue SocketError
   $log.puts "socket error"
   l_exit_status = false
rescue Timeout::Error
   $log.puts "you only get 2 seconds to come and get the data"
   l_exit_status = false
rescue Errno::EBADF
   $log.puts "could not open connection"
   l_exit_status = false
ensure
   l_socket.close if l_socket
end #begin/rescue

   l_exit_status
end #thread/do
</code>

I don't think I have a race condition here, do I?

~S