proxygen
TelnetClient.cpp File Reference

Go to the source code of this file.

Classes

class  TelnetHandler
 
class  TelnetPipelineFactory
 

Typedefs

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

Functions

 DEFINE_int32 (port, 23,"test telnet server port")
 
 DEFINE_string (host,"::1","test telnet server address")
 
int main (int argc, char **argv)
 

Typedef Documentation

Definition at line 34 of file TelnetClient.cpp.

Function Documentation

DEFINE_int32 ( port  ,
23  ,
"test telnet server port"   
)
DEFINE_string ( host  ,
"::1"  ,
"test telnet server address"   
)
int main ( int  argc,
char **  argv 
)

Definition at line 67 of file TelnetClient.cpp.

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

67  {
68  folly::Init init(&argc, &argv);
69 
71  client.group(std::make_shared<folly::IOThreadPoolExecutor>(1));
72  client.pipelineFactory(std::make_shared<TelnetPipelineFactory>());
73  auto pipeline = client.connect(SocketAddress(FLAGS_host,FLAGS_port)).get();
74 
75  try {
76  while (true) {
77  std::string line;
78  std::getline(std::cin, line);
79  if (line == "") {
80  break;
81  }
82 
83  // Sync write will throw exception if server goes away
84  pipeline->write(line + "\r\n").get();
85  if (line == "bye") {
86  pipeline->close();
87  break;
88  }
89  }
90  } catch(const std::exception& e) {
91  std::cout << exceptionStr(e) << std::endl;
92  }
93 
94  return 0;
95 }
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)