本文整理汇总了C++中SSLSocket::setContext方法的典型用法代码示例。如果您正苦于以下问题:C++ SSLSocket::setContext方法的具体用法?C++ SSLSocket::setContext怎么用?C++ SSLSocket::setContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SSLSocket
的用法示例。
在下文中一共展示了SSLSocket::setContext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: server
int
main(int argc, char *argv[])
{
std::cout << "SSLDemo Copyright (C) 2015, W. B. Yates" << std::endl;
std::cout << "This program comes with ABSOLUTELY NO WARRANTY; for details see http://www.gnu.org/licenses/." << std::endl;
std::cout << "This is free software, and you are welcome to redistribute it" << std::endl;
std::cout << "under certain conditions; see http://www.gnu.org/licenses/" << std::endl;
SSLContext ctx1("client", "client.pem", "password");
SSLContext ctx2("server", "server.pem", "password", true);
SSLSocket::registerContext( &ctx1 );
SSLSocket::registerContext( &ctx2 );
SSLSocket client;
client.setContext("client");
SSLSocket server("server");
//Socket client;
//Socket server;
for (int i = 0; i < 5; ++i)
{
std::cout << "\nBegin socket test " << i + 1 << std::endl;
std::thread thread1 = std::thread(rec,&server);
std::thread thread2;
if (i == 0)
thread2 = std::thread(sender1,&client);
else thread2 = std::thread(sender2,&client);
thread1.join();
thread2.join();
}
SSLSocket::clearRegister();
std::cout << "End socket test" << std::endl;
return 0;
}