当前位置: 首页>>代码示例>>C++>>正文


C++ ListenSocket::getPort方法代码示例

本文整理汇总了C++中ListenSocket::getPort方法的典型用法代码示例。如果您正苦于以下问题:C++ ListenSocket::getPort方法的具体用法?C++ ListenSocket::getPort怎么用?C++ ListenSocket::getPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ListenSocket的用法示例。


在下文中一共展示了ListenSocket::getPort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: mcr

TEST(libmcrouter, listenSock) {
  /* Create a listen socket, pass it to a child mcrouter and
     check that communication through the socket works */
  using namespace facebook::memcache;

  ListenSocket listenSock;

  std::vector<std::string> args{MCROUTER_INSTALL_PATH "mcrouter/mcrouter",
        "--listen-sock-fd", folly::to<std::string>(listenSock.getSocketFd()),
        "--config-str", configString };
  auto testArgs = defaultTestCommandLineArgs();
  args.insert(args.end(), testArgs.begin(), testArgs.end());
  folly::Subprocess mcr(args);

  SCOPE_EXIT {
    mcr.terminate();
    mcr.wait();
  };

  const std::string kSetRequest = "set testkey 0 0 1\r\nv\r\n";
  const std::string kStoredReply = "STORED\r\n";
  const std::string kGetRequest = "get testkey\r\n";
  const std::string kGetReply = "VALUE testkey 0 1\r\nv\r\nEND\r\n";

  ClientSocket mcrSock(listenSock.getPort());
  EXPECT_EQ(kStoredReply, mcrSock.sendRequest(kSetRequest));
  EXPECT_EQ(kGetReply, mcrSock.sendRequest(kGetRequest));

  ClientSocket mcSock(memcacheLocal->getPort());
  EXPECT_EQ(kGetReply, mcSock.sendRequest(kGetRequest));
}
开发者ID:sravan64,项目名称:mcrouter,代码行数:31,代码来源:libmcrouter_test.cpp

示例2: umbrellaBinaryReply

void umbrellaBinaryReply(std::string data, mc_res_t expectedResult) {
  ListenSocket sock;

  std::thread serverThread([&sock, &data] {
    auto sockFd = ::accept(sock.getSocketFd(), nullptr, nullptr);
    // Don't read anything, just reply with a serialized reply.
    size_t n = folly::writeFull(sockFd, data.data(), data.size());
    CHECK(n == data.size());
  });

  TestClient client("localhost", sock.getPort(), 200, mc_umbrella_protocol);
  client.sendGet("test", expectedResult);
  client.waitForReplies();
  serverThread.join();
}
开发者ID:PPC64,项目名称:mcrouter,代码行数:15,代码来源:AsyncMcClientTestSync.cpp


注:本文中的ListenSocket::getPort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。