Logan Capaldo wrote:
···
On Aug 8, 2006, at 8:28 AM, Francis Cianfrocca wrote:
It ain't perfect, but:
require 'timeout'
require 'socket'
port = 2200
server = nil
Timeout::timeout(2.0) do
begin
begin
server = TCPServer.new( port )
rescue Errno::EADDRINUSE
port += 1
retry
end
rescue Timeout::Error
puts "Gave up trying to get a port"
exit 1
end
endclient = TCPClient.new( 'localhost', port )
Of course. Still, I don't like this because what about well-secured
server machines with local firewall configurations that don't permit
this kind of swiss cheese? (Well, except for Windows servers, I guess-
anything that has to run Active Directory is hopeless in regard to
firewalls anyway.)
--
Posted via http://www.ruby-forum.com/\.