# File tokyotyrant.rb, line 98 def open(host, port = 0) host = _argstr(host) port = _argnum(port) if @sock @ecode = EINVALID return false end if port > 0 begin info = TCPSocket.gethostbyname(host) rescue Exception @ecode = ENOHOST return false end begin sock = TCPSocket.open(info[3], port) rescue Exception @ecode = EREFUSED return false end else begin sock = UNIXSocket.open(host) rescue Exception @ecode = EREFUSED return false end end @sock = sock return true end