本文整理汇总了C++中Sock::get_sinful_peer方法的典型用法代码示例。如果您正苦于以下问题:C++ Sock::get_sinful_peer方法的具体用法?C++ Sock::get_sinful_peer怎么用?C++ Sock::get_sinful_peer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sock
的用法示例。
在下文中一共展示了Sock::get_sinful_peer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: daemon
bool
CCBListener::DoReversedCCBConnect( char const *address, char const *connect_id, char const *request_id, char const *peer_description )
{
Daemon daemon( DT_ANY, address );
CondorError errstack;
Sock *sock = daemon.makeConnectedSocket(
Stream::reli_sock,CCB_TIMEOUT,0,&errstack,true /*nonblocking*/);
ClassAd *msg_ad = new ClassAd;
ASSERT( msg_ad );
msg_ad->Assign( ATTR_CLAIM_ID, connect_id );
msg_ad->Assign( ATTR_REQUEST_ID, request_id );
// the following is put in the message because that is an easy (lazy)
// way to make it available to ReportReverseConnectResult
msg_ad->Assign( ATTR_MY_ADDRESS, address);
if( !sock ) {
// Failed to create socket or initiate connect
ReportReverseConnectResult(msg_ad,false,"failed to initiate connection");
delete msg_ad;
return false;
}
if( peer_description ) {
char const *peer_ip = sock->peer_ip_str();
if( peer_ip && !strstr(peer_description,peer_ip)) {
MyString desc;
desc.formatstr("%s at %s",peer_description,sock->get_sinful_peer());
sock->set_peer_description(desc.Value());
}
else {
sock->set_peer_description(peer_description);
}
}
incRefCount(); // do not delete self until called back
MyString sock_desc;
int rc = daemonCore->Register_Socket(
sock,
sock->peer_description(),
(SocketHandlercpp)&CCBListener::ReverseConnected,
"CCBListener::ReverseConnected",
this);
if( rc < 0 ) {
ReportReverseConnectResult(msg_ad,false,"failed to register socket for non-blocking reversed connection");
delete msg_ad;
delete sock;
decRefCount();
return false;
}
rc = daemonCore->Register_DataPtr(msg_ad);
ASSERT( rc );
return true;
}