本文整理汇总了C++中network::Socket方法的典型用法代码示例。如果您正苦于以下问题:C++ network::Socket方法的具体用法?C++ network::Socket怎么用?C++ network::Socket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类network
的用法示例。
在下文中一共展示了network::Socket方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Socket
// Ensure that a certificate that WAS generated using the certificate
// authority is NOT allowed to communicate when the SSL_REQUIRE_CERT
// flag is enabled.
TEST_F(SSLTest, RequireCertificate)
{
Try<Socket> server = setup_server({
{"SSL_ENABLED", "true"},
{"SSL_KEY_FILE", key_path().value},
{"SSL_CERT_FILE", certificate_path().value},
{"SSL_REQUIRE_CERT", "true"}});
ASSERT_SOME(server);
Try<Subprocess> client = launch_client({
{"SSL_ENABLED", "true"},
{"SSL_KEY_FILE", key_path().value},
{"SSL_CERT_FILE", certificate_path().value},
{"SSL_REQUIRE_CERT", "true"}},
server.get(),
true);
ASSERT_SOME(client);
Future<Socket> socket = server.get().accept();
AWAIT_ASSERT_READY(socket);
// TODO(jmlvanre): Remove const copy.
AWAIT_ASSERT_EQ(data, Socket(socket.get()).recv());
AWAIT_ASSERT_READY(Socket(socket.get()).send(data));
AWAIT_ASSERT_READY(await_subprocess(client.get(), 0));
}
示例2: Socket
// Ensure that a certificate that was not generated using the
// certificate authority is still allowed to communicate as long as
// the LIBPROCESS_SSL_VERIFY_CERT and LIBPROCESS_SSL_REQUIRE_CERT
// flags are disabled.
TEST_F(SSLTest, NoVerifyBadCA)
{
Try<Socket> server = setup_server({
{"LIBPROCESS_SSL_ENABLED", "true"},
{"LIBPROCESS_SSL_KEY_FILE", key_path().string()},
{"LIBPROCESS_SSL_CERT_FILE", certificate_path().string()},
{"LIBPROCESS_SSL_VERIFY_CERT", "false"},
{"LIBPROCESS_SSL_REQUIRE_CERT", "false"}});
ASSERT_SOME(server);
Try<Subprocess> client = launch_client({
{"LIBPROCESS_SSL_ENABLED", "true"},
{"LIBPROCESS_SSL_KEY_FILE", scrap_key_path().string()},
{"LIBPROCESS_SSL_CERT_FILE", scrap_certificate_path().string()},
{"LIBPROCESS_SSL_REQUIRE_CERT", "true"},
{"LIBPROCESS_SSL_CA_FILE", certificate_path().string()}},
server.get(),
true);
ASSERT_SOME(client);
Future<Socket> socket = server.get().accept();
AWAIT_ASSERT_READY(socket);
// TODO(jmlvanre): Remove const copy.
AWAIT_ASSERT_EQ(data, Socket(socket.get()).recv());
AWAIT_ASSERT_READY(Socket(socket.get()).send(data));
AWAIT_ASSERT_READY(await_subprocess(client.get(), 0));
}