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.
5 // A binary wrapper for QuicServer. It listens forever on --port
6 // (default 6121) until it's killed or ctrl-cd to death.
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"
16 // The port the quic server will listen on.
18 int32 FLAGS_port
= 6121;
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");
28 if (line
->HasSwitch("port")) {
30 if (base::StringToInt(line
->GetSwitchValueASCII("port"), &port
)) {
35 base::AtExitManager exit_manager
;
37 net::IPAddressNumber ip
;
38 CHECK(net::ParseIPLiteralToNumber("::", &ip
));
40 net::tools::QuicServer server
;
42 if (!server
.Listen(net::IPEndPoint(ip
, FLAGS_port
))) {
47 server
.WaitForEvents();