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 QuicClient. Connects to --hostname or --address on
6 // --port and requests URLs specified on the command line.
9 // quic_client --port=6122 /index.html /favicon.ico
11 #include "base/at_exit.h"
12 #include "base/command_line.h"
13 #include "base/logging.h"
14 #include "base/strings/string_number_conversions.h"
15 #include "net/base/ip_endpoint.h"
16 #include "net/quic/quic_protocol.h"
17 #include "net/tools/quic/quic_client.h"
19 int32 FLAGS_port
= 6121;
20 std::string FLAGS_address
= "127.0.0.1";
21 std::string FLAGS_hostname
= "localhost";
23 int main(int argc
, char *argv
[]) {
24 CommandLine::Init(argc
, argv
);
25 CommandLine
* line
= CommandLine::ForCurrentProcess();
26 if (line
->HasSwitch("port")) {
28 if (base::StringToInt(line
->GetSwitchValueASCII("port"), &port
)) {
32 if (line
->HasSwitch("address")) {
33 FLAGS_address
= line
->GetSwitchValueASCII("address");
35 if (line
->HasSwitch("hostname")) {
36 FLAGS_hostname
= line
->GetSwitchValueASCII("hostname");
38 LOG(INFO
) << "server port: " << FLAGS_port
39 << " address: " << FLAGS_address
40 << " hostname: " << FLAGS_hostname
;
42 base::AtExitManager exit_manager
;
44 net::IPAddressNumber addr
;
45 CHECK(net::ParseIPLiteralToNumber(FLAGS_address
, &addr
));
46 // TODO(rjshade): Set version on command line.
47 net::tools::QuicClient
client(
48 net::IPEndPoint(addr
, FLAGS_port
), FLAGS_hostname
, net::QuicVersionMax());
52 if (!client
.Connect()) return 1;
54 client
.SendRequestsAndWaitForResponse(line
->GetArgs());