本文整理汇总了C++中Sock::get_peer_version方法的典型用法代码示例。如果您正苦于以下问题:C++ Sock::get_peer_version方法的具体用法?C++ Sock::get_peer_version怎么用?C++ Sock::get_peer_version使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sock
的用法示例。
在下文中一共展示了Sock::get_peer_version方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
dprintf(D_FULLDEBUG,"locating collector %s...\n", collector->name());
if(!collector->locate()) {
fprintf(stderr,"couldn't locate collector: %s\n",collector->error());
had_error = true;
continue;
}
dprintf(D_FULLDEBUG,"collector is %s located at %s\n",
collector->hostname(),collector->addr());
sock = NULL;
ClassAd *ad;
int success_count = 0;
int failure_count = 0;
ads.Rewind();
while( (ad=ads.Next()) ) {
// If there's no "MyAddress", generate one..
if( !ad->Lookup( ATTR_MY_ADDRESS ) ) {
MyString tmp;
tmp.formatstr( "<%s:0>", my_ip_string() );
ad->Assign( ATTR_MY_ADDRESS, tmp.Value() );
}
if ( use_tcp ) {
if( !sock ) {
sock = collector->startCommand(command,Stream::reli_sock,20);
}
else {
// Use existing connection.
sock->encode();
sock->put(command);
}
} else {
// We must open a new UDP socket each time.
delete sock;
sock = collector->startCommand(command,Stream::safe_sock,20);
}
int result = 0;
if ( sock ) {
result += ad->put( *sock );
result += sock->end_of_message();
}
if ( result != 2 ) {
fprintf(stderr,"failed to send classad to %s\n",collector->addr());
had_error = true;
failure_count++;
delete sock;
sock = NULL;
continue;
}
if( with_ack ) {
sock->decode();
int ok = 0;
if( !sock->get(ok) || !sock->end_of_message() ) {
fprintf(stderr,"failed to get ack from %s\n",collector->addr());
had_error = true;
failure_count++;
delete sock;
sock = NULL;
continue;
}
// ack protocol does not allow for multiple updates,
// so close the socket now
delete sock;
sock = NULL;
}
success_count++;
}
if( sock ) {
CondorVersionInfo const *ver = sock->get_peer_version();
if( !ver || ver->built_since_version(7,7,3) ) {
// graceful hangup so the collector knows we are done
sock->encode();
command = DC_NOP;
sock->put(command);
sock->end_of_message();
}
delete sock;
sock = NULL;
}
printf("Sent %d of %d ad%s to %s.\n",
success_count,
success_count + failure_count,
success_count+failure_count == 1 ? "" : "s",
collector->name());
}
delete collectors;
return (had_error)?1:0;
}