# File ruby/comm_xmlrpc.rb, line 84
        def check_previous_port(way,port)
          begin
                s = TCPSocket.open("localhost", port)
                s.close
                #someone using the port
                case way
                when :reuse
                  puts "Port:#{port} has been opened. Trying to reuse the port..."
                  return nil
                when :kill
                  puts "Port:#{port} has been opened. Trying to kill the port..."
                  client = XMLRPC::Client.new("localhost", "/RPC2", port)
                  client.call2("jb.exit")
                  return 0
                when :abort
                  puts "Port:#{port} has been opened. Abort this program."
                  abort
                end
          rescue Errno::ECONNREFUSED => e
                #no connection
                return 0
          rescue => e
                puts "Failed to deal with the opened port..."
                abort
          end
        end