本文整理汇总了C++中Owned::createSecureSocket方法的典型用法代码示例。如果您正苦于以下问题:C++ Owned::createSecureSocket方法的具体用法?C++ Owned::createSecureSocket怎么用?C++ Owned::createSecureSocket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Owned
的用法示例。
在下文中一共展示了Owned::createSecureSocket方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doSendQuery
int doSendQuery(const char * ip, unsigned port, const char * base)
{
Owned<ISocket> socket;
Owned<ISecureSocketContext> secureContext;
__int64 starttime, endtime;
StringBuffer ipstr;
try
{
if (strcmp(ip, ".")==0)
ip = GetCachedHostName();
else
{
const char *dash = strchr(ip, '-');
if (dash && isdigit(dash[1]) && dash>ip && isdigit(dash[-1]))
{
if (persistConnections)
UNIMPLEMENTED;
const char *startrange = dash-1;
while (isdigit(startrange[-1]))
startrange--;
char *endptr;
unsigned firstnum = atoi(startrange);
unsigned lastnum = strtol(dash+1, &endptr, 10);
if (lastnum > firstnum)
{
static unsigned counter;
static CriticalSection counterCrit;
CriticalBlock b(counterCrit);
ipstr.append(startrange - ip, ip).append((counter++ % (lastnum+1-firstnum)) + firstnum).append(endptr);
ip = ipstr.str();
printf("Sending to %s\n", ip);
}
}
}
starttime= get_cycles_now();
if (persistConnections)
{
if (!persistSocket)
{
SocketEndpoint ep(ip,port);
persistSocket.setown(ISocket::connect_timeout(ep, 1000));
if (useSSL)
{
#ifdef _USE_OPENSSL
if (!persistSecureContext)
persistSecureContext.setown(createSecureSocketContext(ClientSocket));
persistSSock.setown(persistSecureContext->createSecureSocket(persistSocket.getClear()));
persistSSock->secure_connect();
persistSocket.setown(persistSSock.getClear());
#else
throw MakeStringException(-1, "OpenSSL disabled in build");
#endif
}
}
socket = persistSocket;
}
else
{
SocketEndpoint ep(ip,port);
socket.setown(ISocket::connect_timeout(ep, 100000));
if (useSSL)
{
#ifdef _USE_OPENSSL
secureContext.setown(createSecureSocketContext(ClientSocket));
Owned<ISecureSocket> ssock = secureContext->createSecureSocket(socket.getClear());
ssock->secure_connect();
socket.setown(ssock.getClear());
#else
throw MakeStringException(1, "OpenSSL disabled in build");
#endif
}
}
}
catch(IException * e)
{
pexception("failed to connect to server", e);
return 1;
}
StringBuffer fullQuery;
bool useHTTP = forceHTTP || strstr(base, "<soap:Envelope") != NULL;
if (useHTTP)
{
StringBuffer newQuery;
Owned<IPTree> p = createPTreeFromXMLString(base, ipt_none, ptr_none);
const char *queryName = p->queryName();
if ((stricmp(queryName, "envelope") != 0) && (stricmp(queryName, "envelope") != 0))
{
if (queryNameOverride.length())
queryName = queryNameOverride;
newQuery.appendf("<Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><Body><%sRequest>", queryName);
Owned<IPTreeIterator> elements = p->getElements("./*");
ForEach(*elements)
{
IPTree &elem = elements->query();
toXML(&elem, newQuery, 0, XML_SingleQuoteAttributeValues);
}
newQuery.appendf("</%sRequest></Body></Envelope>", queryName);
base = newQuery.str();
}
//.........这里部分代码省略.........