From: Eric Wong Date: 2011-07-28T03:05:57+09:00 Subject: [ruby-core:38568] Re: [Ruby 1.9 - Feature #5101][Open] allow optional timeout for TCPSocket.new Eric Wong wrote: > Proposed API would be: > > TCPSocket.new(remote_host, remote_port, > connect_timeout: 0.5, local_host: nil, local_port: nil) An alternative (or complimentary) API could also be to add a new class method that only starts the TCP connection, but returns the socket on EINPROGRESS: TCPSocket.start(remote_host, remote_port, local_host=nil, local_port=nil) => tcp_socket This means the user would have to wait for writability on the socket returned by this method (e.g. with IO.select). I've already implemented something similar for kgio: http://bogomips.org/kgio/Kgio/TCPSocket.html#method-c-start .. and am of course happy to provide patches for Ruby itself if ruby-core agrees it's a good API to have :> -- Eric Wong