--- David Alan Black <dblack / candle.superlink.net>
wrote:
> Hello --
> 
> 
> On Wed, 8 Aug 2001, Joseph McDonald wrote:
> 
> >
> > Hi,
> >
> > I have a bit of a chicken and egg problem here.  I
> want to use timeout
> > to initiate a socket connection, but have a
> timeout on the connection.
> > However if I use Timeout, the socket is out of
> scope by the time I
> > get connected.  Can I somehow declare "s" as a
> socket above without
> > trying to connect?
> >
> >   begin
> >     timeout(5) do
> >       s = TCPSocket.new(host, port)
> >     end
> >   rescue TimeoutError
> >     puts "failed initial connect, retrying..."
> >     retry
> >   rescue
> >     puts "failed #{$!}... retrying"
> >     retry
> >   end
> >   # s is no longer available here.
> 
> Wouldn't it work just to say:
> 
>   s = nil
> 
> before the block?
> 
> 

Good point, but also:  Why would you want the messed
up socket object anyway?  Maybe you should put it all
inside the begin block.

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/