本文整理汇总了C++中DNSServiceProcessResult函数的典型用法代码示例。如果您正苦于以下问题:C++ DNSServiceProcessResult函数的具体用法?C++ DNSServiceProcessResult怎么用?C++ DNSServiceProcessResult使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DNSServiceProcessResult函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessDNSMessages
void ProcessDNSMessages() {
static boolean initialized;
if ( !initialized ) {
initialized = true;
DNSServiceErrorType err = DNSServiceBrowse (
&browseRef,
0, /* flags */
0, /* interface */
serviceName,
NULL, /* domain */
DNSServiceBrowseReplyCallback,
NULL /* context */
);
if ( err != kDNSServiceErr_NoError ) {
printf( "DNSServiceBrowse error\n" );
return;
}
}
// poll the socket for updates
int socket = DNSServiceRefSockFD( browseRef );
if ( socket <= 0 ) {
return;
}
fd_set set;
FD_ZERO( &set );
FD_SET( socket, &set );
struct timeval tv;
memset( &tv, 0, sizeof( tv ) );
if ( select( socket+1, &set, NULL, NULL, &tv ) > 0 ) {
DNSServiceProcessResult( browseRef );
}
}
示例2: lock
void CZeroconfWIN::ProcessResults()
{
CSingleLock lock(m_data_guard);
DNSServiceErrorType err = DNSServiceProcessResult(m_service);
if (err != kDNSServiceErr_NoError)
CLog::Log(LOGERROR, "ZeroconfWIN: DNSServiceProcessResult returned (error = %ld)", (int) err);
}
示例3: OW_Browse_Bonjour
// Called in a thread
static void * OW_Browse_Bonjour(void * v)
{
struct connection_in * in = v ;
DNSServiceErrorType dnserr;
DETACH_THREAD;
MONITOR_RLOCK ;
dnserr = DNSServiceBrowse(&in->master.browse.bonjour_browse, 0, 0, "_owserver._tcp", NULL, BrowseBack, NULL);
if (dnserr != kDNSServiceErr_NoError) {
LEVEL_CONNECT("DNSServiceBrowse error = %d", dnserr);
MONITOR_RUNLOCK ;
return VOID_RETURN ;
}
// Blocks, which is why this is in it's own thread
while (DNSServiceProcessResult(in->master.browse.bonjour_browse) == kDNSServiceErr_NoError) {
//printf("DNSServiceProcessResult ref %ld\n",(long int)rs->sref) ;
continue;
}
DNSServiceRefDeallocate(in->master.browse.bonjour_browse);
in->master.browse.bonjour_browse = 0 ;
MONITOR_RUNLOCK ;
return VOID_RETURN;
}
示例4: DNSServiceRefSockFD
void AutoDiscoveryServerImpl::update()
{
int dns_sd_fd = client ? DNSServiceRefSockFD(client ) : -1;
int nfds = dns_sd_fd + 1;
fd_set readfds;
struct timeval tv;
int result;
// (dns_sd_fd2 > dns_sd_fd) nfds = dns_sd_fd2 + 1;
// 1. Set up the fd_set as usual here.
// This example client has no file descriptors of its own,
// but a real application would call FD_SET to add them to the set here
FD_ZERO(&readfds);
// 2. Add the fd for our client(s) to the fd_set
if (client ) FD_SET(dns_sd_fd , &readfds);
//if (client_pa) FD_SET(dns_sd_fd2, &readfds);
// 3. Set up the timeout.
tv.tv_sec = 0;
tv.tv_usec = 0;
result = select(nfds, &readfds, (fd_set*)NULL, (fd_set*)NULL, &tv);
if (result > 0)
{
DNSServiceErrorType err = kDNSServiceErr_NoError;
if (client && FD_ISSET(dns_sd_fd , &readfds)) err = DNSServiceProcessResult(client );
// else if (client_pa && FD_ISSET(dns_sd_fd2, &readfds)) err = DNSServiceProcessResult(client_pa);
// if (err) { fprintf(stderr, "DNSServiceProcessResult returned %d\n", err); stopNow = 1; }
}
}
示例5: wxASSERT
void * wxServiceDiscoveryTaskBase::wxServiceDiscoveryServiceHelperThread::Entry()
{
// static wxCriticalSection section;
// wxCriticalSectionLocker section_locker( section );
wxASSERT( ! wxThread::IsMain() );
bool cancel_running = false;
DNSServiceErrorType err = kDNSServiceErr_NoError;
do
{
err = DNSServiceProcessResult( m_ServiceRef );
if ( err )
{
if ( err == kDNSServiceErr_Unknown )
{
wxLogDebug( wxT("Received an unknown bonjour error, but this was probably just a method of quitting our thread.") );
}
else
{
wxLogDebug( wxT("got error! %d"),
err );
}
cancel_running = true;
}
} while ( ! TestDestroy() && !cancel_running );
return NULL;
}
示例6: DNSServiceResolve
bool CZeroconfBrowserWIN::doResolveService(CZeroconfBrowser::ZeroconfService& fr_service, double f_timeout)
{
DNSServiceErrorType err;
DNSServiceRef sdRef = NULL;
err = DNSServiceResolve(&sdRef, 0, kDNSServiceInterfaceIndexAny, fr_service.GetName(), fr_service.GetType(), fr_service.GetDomain(), ResolveCallback, &fr_service);
if( err != kDNSServiceErr_NoError )
{
if (sdRef)
DNSServiceRefDeallocate(sdRef);
CLog::Log(LOGERROR, "ZeroconfBrowserWIN: DNSServiceResolve returned (error = %ld)", (int) err);
return false;
}
err = DNSServiceProcessResult(sdRef);
if (err != kDNSServiceErr_NoError)
CLog::Log(LOGERROR, "ZeroconfBrowserWIN::doResolveService DNSServiceProcessResult returned (error = %ld)", (int) err);
if (sdRef)
DNSServiceRefDeallocate(sdRef);
return true;
}
示例7: FD_ZERO
ConnectionError Client::recv( int timeout )
{
if( m_connection && m_connection->state() == StateConnected )
return ClientBase::recv( timeout );
else
{
if( !m_currentRef )
return ConnNoError;
struct timeval tv;
fd_set fds;
FD_ZERO( &fds );
// the following causes a C4127 warning in VC++ Express 2008 and possibly other versions.
// however, the reason for the warning can't be fixed in gloox.
FD_SET( DNSServiceRefSockFD( m_currentRef ), &fds );
tv.tv_sec = timeout / 1000000;
tv.tv_usec = timeout % 1000000;
if( select( FD_SETSIZE, &fds, 0, 0, timeout == -1 ? 0 : &tv ) > 0 )
{
if( FD_ISSET( DNSServiceRefSockFD( m_currentRef ), &fds ) != 0 )
DNSServiceProcessResult( m_currentRef );
}
return ConnNoError;
}
}
示例8: DNSServiceProcessResult
void ZeroconfBrowser::socketReadyRead()
{
DNSServiceErrorType err = DNSServiceProcessResult(m_DnsServiceRef);
if (err != kDNSServiceErr_NoError) {
emit error(err);
}
}
示例9: register_service
void register_service(DNSServiceRef service) {
// Run until break.
int dns_sd_fd = DNSServiceRefSockFD(service);
fd_set readfds;
struct timeval tv;
int result;
while (should_run()) {
FD_ZERO(&readfds);
FD_SET(dns_sd_fd, &readfds);
tv.tv_sec = LONG_TIME;
tv.tv_usec = 0;
// highest fd in set + 1
result = select(dns_sd_fd+1, &readfds, (fd_set*)NULL, (fd_set*)NULL, &tv);
if (result > 0) {
DNSServiceErrorType err = kDNSServiceErr_NoError;
// Execute callback
if (FD_ISSET(dns_sd_fd, &readfds)) err = DNSServiceProcessResult(service);
if (err) {
// An error occured. Halt.
fprintf(stderr, "DNSServiceProcessResult returned %d\n", err);
quit();
}
} else if (errno != EINTR) {
// Error.
fprintf(stderr, "ZeroConf error (%d %s)\n", errno, strerror(errno));
if (errno != EINTR) quit();
}
}
}
示例10: _ptpip_enumerate
static void
_ptpip_enumerate (
DNSServiceRef sdRef, DNSServiceFlags flags,
uint32_t interfaceIndex, DNSServiceErrorType errorCode,
const char *serviceName, const char *regtype, const char *replyDomain,
void *context
) {
struct mdnsinfo mdnsi;
DNSServiceRef sd;
if (errorCode != kDNSServiceErr_NoError) {
gp_log (GP_LOG_ERROR, "ptpip", "Error on _ptp._tcp query.");
return;
}
gp_log (GP_LOG_DEBUG, "ptpip", "found %s, %s, %s", serviceName, regtype, replyDomain);
mdnsi.list = context;
mdnsi.name = serviceName;
DNSServiceResolve (&sd,
0,
interfaceIndex,
serviceName,
regtype,
replyDomain,
_ptpip_resolved,
&mdnsi
);
DNSServiceProcessResult (sd);
DNSServiceRefDeallocate (sd);
}
示例11: _SocketCallBack
/* static */ void
_SocketCallBack(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void* data, void* info) {
DNSServiceErrorType err;
__CFNetServiceBrowser* browser = info;
(void)s; // unused
(void)type; // unused
(void)address; // unused
(void)data; // unused
CFRetain(browser);
// Dispatch to process the result
err = DNSServiceProcessResult(browser->_browse);
// If there was an error, need to infor the client.
if (err) {
// Dispatch based upon search type.
if (browser->_domainSearch)
_DomainEnumReply(browser->_browse, 0, 0, err, NULL, info);
else
_BrowseReply(browser->_browse, 0, 0, err, NULL, NULL, NULL, info);
}
CFRelease(browser);
}
示例12: assert
bool MLNetServiceHub::pollService(DNSServiceRef dnsServiceRef, double timeOutInSeconds, DNSServiceErrorType &err)
{
assert(dnsServiceRef);
err = kDNSServiceErr_NoError;
fd_set readfds;
FD_ZERO(&readfds);
int dns_sd_fd = DNSServiceRefSockFD(dnsServiceRef);
int nfds = dns_sd_fd+1;
FD_SET(dns_sd_fd, &readfds);
struct timeval tv;
tv.tv_sec = long(floor(timeOutInSeconds));
tv.tv_usec = long(1000000*(timeOutInSeconds - tv.tv_sec));
int result = select(nfds,&readfds,NULL,NULL,&tv);
if(result>0 && FD_ISSET(dns_sd_fd, &readfds))
{
err = DNSServiceProcessResult(dnsServiceRef);
return true;
}
return false;
}
示例13: socket_callback
/*
* CFRunloop callback that calls DNSServiceProcessResult() when
* there's new data on the socket.
*/
static void
socket_callback(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void *data, void *context)
{
struct cbinfo *info = context;
DNSServiceErrorType err;
if (callbackType == kCFSocketNoCallBack) {
printf("socket_callback: kCFSocketNoCallBack?\n");
return;
}
if ((err = DNSServiceProcessResult(info->sdref)) != kDNSServiceErr_NoError) {
printf("DNSServiceProcessResult() returned an error! %d\n", err);
if (err == kDNSServiceErr_BadReference) {
printf("bad reference?: %p, %d, %p, %p %p\n", s, (int)callbackType, address, data, context);
return;
}
if ((context == &nfsinfo) || (context == &mountdinfo)) {
/* bail if there's a problem with the main browse connection */
exit(1);
}
/* dump the troublesome service connection */
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), info->rls, kCFRunLoopDefaultMode);
CFRelease(info->rls);
CFSocketInvalidate(info->sockref);
CFRelease(info->sockref);
DNSServiceRefDeallocate(info->sdref);
free(info);
}
}
示例14: dlog
LONG
CSecondPage::OnServiceEvent(WPARAM inWParam, LPARAM inLParam)
{
if (WSAGETSELECTERROR(inLParam) && !(HIWORD(inLParam)))
{
dlog( kDebugLevelError, "OnServiceEvent: window error\n" );
}
else
{
SOCKET sock = (SOCKET) inWParam;
// iterate thru list
ServiceRefList::iterator begin = m_serviceRefList.begin();
ServiceRefList::iterator end = m_serviceRefList.end();
while (begin != end)
{
DNSServiceRef ref = *begin++;
check(ref != NULL);
if ((SOCKET) DNSServiceRefSockFD(ref) == sock)
{
DNSServiceProcessResult(ref);
break;
}
}
}
return ( 0 );
}
示例15: switch
LRESULT CALLBACK wxServiceDiscoveryTaskBase::WndProc(HWND inWindow,
UINT inMsg,
WPARAM inWParam,
LPARAM inLParam )
{
LRESULT result;
switch(inMsg)
{
case DNSSD_EVENT:
// Process the DNS-SD event. All DNS-SD callbacks occur from
// within this function.
{
void * ptr = GetProp( inWindow, PROPNAME );
wxServiceDiscoveryTaskBase * self = reinterpret_cast<wxServiceDiscoveryTaskBase *>( ptr );
if (DNSServiceProcessResult( self->m_rServiceRef ) != kDNSServiceErr_NoError)
result = -1;
else
result = 0;
}
break;
case WM_NCDESTROY:
RemoveProp( inWindow, PROPNAME );
// fall through
default:
result = DefWindowProc(inWindow, inMsg, inWParam, inLParam);
break;
}
return(result);
}