proxygen
EchoClient.cpp File Reference

Go to the source code of this file.

Classes

class  EchoHandler
 
class  EchoPipelineFactory
 

Typedefs

typedef Pipeline< folly::IOBufQueue &, std::stringEchoPipeline
 

Functions

 DEFINE_int32 (port, 8080,"echo server port")
 
 DEFINE_string (host,"::1","echo server address")
 
int main (int argc, char **argv)
 

Typedef Documentation

Definition at line 34 of file EchoClient.cpp.

Function Documentation

DEFINE_int32 ( port  ,
8080  ,
"echo server port"   
)
DEFINE_string ( host  ,
"::1"  ,
"echo server address"   
)
int main ( int  argc,
char **  argv 
)

Definition at line 69 of file EchoClient.cpp.

References wangle::ClientBootstrap< Pipeline >::connect(), folly::exceptionStr(), getline(), wangle::ClientBootstrap< Pipeline >::group(), folly::init(), wangle::BaseClientBootstrap< Pipeline >::pipelineFactory(), and string.

69  {
70  folly::Init init(&argc, &argv);
71 
73  client.group(std::make_shared<folly::IOThreadPoolExecutor>(1));
74  client.pipelineFactory(std::make_shared<EchoPipelineFactory>());
75  auto pipeline = client.connect(SocketAddress(FLAGS_host, FLAGS_port)).get();
76 
77  try {
78  while (true) {
79  std::string line;
80  std::getline(std::cin, line);
81  if (line == "") {
82  break;
83  }
84 
85  pipeline->write(line + "\r\n").get();
86  if (line == "bye") {
87  pipeline->close();
88  break;
89  }
90  }
91  } catch (const std::exception& e) {
92  std::cout << exceptionStr(e) << std::endl;
93  }
94 
95  return 0;
96 }
fbstring exceptionStr(const std::exception &e)
void BENCHFUN() getline(size_t iters, size_t arg)
folly::Future< Pipeline * > connect(const folly::SocketAddress &address, std::chrono::milliseconds timeout=std::chrono::milliseconds(0)) override
void init()
char ** argv
BaseClientBootstrap< Pipeline > * pipelineFactory(std::shared_ptr< PipelineFactory< Pipeline >> factory) noexcept
const char * string
Definition: Conv.cpp:212
ClientBootstrap * group(std::shared_ptr< folly::IOThreadPoolExecutor > group)