Logo ROOT   6.10/09
Reference Guide
TBonjourResolver.h
Go to the documentation of this file.
1 // @(#)root/bonjour:$Id$
2 // Author: Fons Rademakers 29/05/2009
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2009, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TBonjourResolver
13 #define ROOT_TBonjourResolver
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TBonjourResolver //
19 // //
20 // This class consists of one main member function, //
21 // ResolveBonjourRecord(), that resolves the service to an actual //
22 // IP address and port number. The rest of the class wraps the various //
23 // bits of Bonjour service resolver. The static callback function //
24 // is marked with the DNSSD_API macro to make sure that the callback //
25 // has the correct calling convention on Windows. //
26 // //
27 //////////////////////////////////////////////////////////////////////////
28 
29 #include "TObject.h"
30 #include "TQObject.h"
31 #include "TInetAddress.h"
32 
33 #if !defined(__CINT__)
34 #include <dns_sd.h>
35 #else
36 typedef ULong_t DNSServiceRef;
37 typedef UInt_t DNSServiceFlags;
38 typedef Int_t DNSServiceErrorType;
39 #endif
40 
41 class TFileHandler;
42 class TBonjourRecord;
43 
44 
45 class TBonjourResolver : public TObject, public TQObject {
46 
47 private:
48  DNSServiceRef fDNSRef;
53 
54  void *GetSender() { return this; } // used to get gTQSender
55 
56 #if !defined(__CINT__)
57  static void DNSSD_API BonjourResolveReply(DNSServiceRef, DNSServiceFlags, UInt_t,
58  DNSServiceErrorType,
59  const char *, const char *,
60  UShort_t, UShort_t, const char *, void *);
61 #else
62  static void BonjourResolveReply(DNSServiceRef, DNSServiceFlags, UInt_t,
63  DNSServiceErrorType,
64  const char *, const char *,
65  UShort_t, UShort_t, const char *, void *);
66 #endif
67 
68 public:
70  virtual ~TBonjourResolver();
71 
73  Int_t GetPort() const { return fPort; }
74  const char * GetTXTRecord() const { return fTXTRecord; }
75 
77 
78  void RecordResolved(const TInetAddress *hostInfo, Int_t port); //*SIGNAL*
79 
80  void BonjourSocketReadyRead(); // private slot
81 
82  ClassDef(TBonjourResolver,0) // Resolve Bonjour to actual IP address and port
83 };
84 
85 #endif
void BonjourSocketReadyRead()
The Bonjour socket is ready for reading.
Int_t ResolveBonjourRecord(const TBonjourRecord &record)
Resolve Bonjour service to IP address and port.
unsigned short UShort_t
Definition: RtypesCore.h:36
This class represents an Internet Protocol (IP) address.
Definition: TInetAddress.h:36
This is the ROOT implementation of the Qt object communication mechanism (see also http://www...
Definition: TQObject.h:49
Basic string class.
Definition: TString.h:129
TBonjourResolver()
Default ctor.
int Int_t
Definition: RtypesCore.h:41
void RecordResolved(const TInetAddress *hostInfo, Int_t port)
Emit RecordResolved signal.
#define ClassDef(name, id)
Definition: Rtypes.h:297
virtual ~TBonjourResolver()
Cleanup.
DNSServiceRef fDNSRef
unsigned int UInt_t
Definition: RtypesCore.h:42
TInetAddress GetInetAddress() const
static void DNSSD_API BonjourResolveReply(DNSServiceRef, DNSServiceFlags, UInt_t, DNSServiceErrorType, const char *, const char *, UShort_t, UShort_t, const char *, void *)
Static Bonjour resolver callback function.
TFileHandler * fBonjourSocketHandler
unsigned long ULong_t
Definition: RtypesCore.h:51
const char * GetTXTRecord() const
Mother of all ROOT objects.
Definition: TObject.h:37
TInetAddress fHostAddress
Int_t GetPort() const