Home | History | Annotate | Download | only in quic
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 //
      5 // A binary wrapper for QuicServer.  It listens forever on --port
      6 // (default 6121) until it's killed or ctrl-cd to death.
      7 
      8 #include "base/at_exit.h"
      9 #include "base/basictypes.h"
     10 #include "base/command_line.h"
     11 #include "base/strings/string_number_conversions.h"
     12 #include "net/base/ip_endpoint.h"
     13 #include "net/tools/quic/quic_in_memory_cache.h"
     14 #include "net/tools/quic/quic_server.h"
     15 
     16 // The port the quic server will listen on.
     17 
     18 int32 FLAGS_port = 6121;
     19 
     20 int main(int argc, char *argv[]) {
     21   CommandLine::Init(argc, argv);
     22   CommandLine* line = CommandLine::ForCurrentProcess();
     23   if (line->HasSwitch("quic_in_memory_cache_dir")) {
     24     net::tools::FLAGS_quic_in_memory_cache_dir =
     25         line->GetSwitchValueASCII("quic_in_memory_cache_dir");
     26   }
     27 
     28   if (line->HasSwitch("port")) {
     29     int port;
     30     if (base::StringToInt(line->GetSwitchValueASCII("port"), &port)) {
     31       FLAGS_port = port;
     32     }
     33   }
     34 
     35   base::AtExitManager exit_manager;
     36 
     37   net::IPAddressNumber ip;
     38   CHECK(net::ParseIPLiteralToNumber("::", &ip));
     39 
     40   net::tools::QuicServer server;
     41 
     42   if (!server.Listen(net::IPEndPoint(ip, FLAGS_port))) {
     43     return 1;
     44   }
     45 
     46   while (1) {
     47     server.WaitForEvents();
     48   }
     49 
     50   return 0;
     51 }
     52