/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2016-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <iostream>
#include <folly/ExceptionWrapper.h>
-#include <gflags/gflags.h>
+#include <folly/portability/GFlags.h>
using namespace folly;
DEFINE_bool(tfo, false, "enable tfo");
DEFINE_string(msg, "", "Message to send");
DEFINE_bool(ssl, false, "use ssl");
+DEFINE_int32(timeout_ms, 0, "timeout");
+DEFINE_int32(sendtimeout_ms, 0, "send timeout");
+DEFINE_int32(num_writes, 1, "number of writes");
int main(int argc, char** argv) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
#endif
}
+ if (FLAGS_sendtimeout_ms != 0) {
+ socket->setSendTimeout(FLAGS_sendtimeout_ms);
+ }
+
// Keep this around
auto sockAddr = socket.get();
SocketAddress addr;
addr.setFromHostPort(FLAGS_host, FLAGS_port);
sock.setAddress(addr);
- sock.open();
+ std::chrono::milliseconds timeout(FLAGS_timeout_ms);
+ sock.open(timeout);
LOG(INFO) << "connected to " << addr.getAddressStr();
- sock.write((const uint8_t*)FLAGS_msg.data(), FLAGS_msg.size());
+ for (int32_t i = 0; i < FLAGS_num_writes; ++i) {
+ sock.write((const uint8_t*)FLAGS_msg.data(), FLAGS_msg.size());
+ }
- LOG(ERROR) << "TFO attempted: " << sockAddr->getTFOAttempted();
- LOG(ERROR) << "TFO finished: " << sockAddr->getTFOFinished();
+ LOG(INFO) << "TFO attempted: " << sockAddr->getTFOAttempted();
+ LOG(INFO) << "TFO finished: " << sockAddr->getTFOFinished();
+ LOG(INFO) << "TFO success: " << sockAddr->getTFOSucceded();
std::array<char, 1024> buf;
int32_t bytesRead = 0;