本文整理汇总了C++中Sock::is_connected方法的典型用法代码示例。如果您正苦于以下问题:C++ Sock::is_connected方法的具体用法?C++ Sock::is_connected怎么用?C++ Sock::is_connected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sock
的用法示例。
在下文中一共展示了Sock::is_connected方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int
CCBListener::ReverseConnected(Stream *stream)
{
Sock *sock = (Sock *)stream;
ClassAd *msg_ad = (ClassAd *)daemonCore->GetDataPtr();
ASSERT( msg_ad );
if( sock ) {
daemonCore->Cancel_Socket( sock );
}
if( !sock || !sock->is_connected() ) {
ReportReverseConnectResult(msg_ad,false,"failed to connect");
}
else {
// The reverse-connect protocol is designed to look like a
// raw cedar command, in case the thing we are connecting
// to is a cedar command socket.
sock->encode();
int cmd = CCB_REVERSE_CONNECT;
if( !sock->put(cmd) ||
!msg_ad->put( *sock ) ||
!sock->end_of_message() )
{
ReportReverseConnectResult(msg_ad,false,"failure writing reverse connect command");
}
else {
((ReliSock*)sock)->isClient(false);
daemonCore->HandleReqAsync(sock);
sock = NULL; // daemonCore took ownership of sock
ReportReverseConnectResult(msg_ad,true);
}
}
delete msg_ad;
if( sock ) {
delete sock;
}
decRefCount(); // we incremented ref count when setting up callback
return KEEP_STREAM;
}