wxServDisc is a C++ class that implements Zeroconf service discovery on UNIX, OS X and Windows without any other dependencies than wxWidgets. a sample application is also included.
you can download the newest version here.

for updates look at WHAT'S NEW.
SDWrap screenshot


1) what is it

wxServDisc is a simple to use C++ class to facilitate Zeroconf service discovery in a wxWidgets application. it works under UNIX, Mac OS X and Windows. wxServDisc uses mdnsd (C) Jer (jer@jabber.org) internally.


2) how to use it

API:

  // type can be one of QTYPE_A, QTYPE_NS, QTYPE_CNAME, QTYPE_PTR or QTYPE_SRV  
  wxServDisc(void* parent, const wxString& what, int type);
  ~wxServDisc();
  
  // yeah well...
  std::vector<wxSDEntry> getResults() const;
  size_t getResultCount() const;

  // get query name;
  const wxString& getQuery() const { const wxString& ref = query; return ref; };
  // get error string
  const wxString& getErr() const { const wxString& ref = err; return ref; };

typically you would do a three-stage query when looking up the address of a service instance:
  wxServDisc *servscan = new wxServDisc(this, wxT("_rfb._tcp.local."), QTYPE_PTR);
  wxServDisc namescan(0, servscan->getResults().at(0).name, QTYPE_SRV);
  wxServDisc addrscan(0, namescan.getResults().at(0).name, QTYPE_A);
  wxString addr = addrscan.getResults().at(0).ip;

ah yes and a wxServDisc instance sends a custom event when sth. is discovered.
so you have to add it to your event table, if you want to use it:
   // map recv of wxServDiscNOTIFY to some method
   BEGIN_EVENT_TABLE(MyFrameMain, FrameMain)
     EVT_COMMAND  (wxID_ANY, wxServDiscNOTIFY, MyFrameMain::onSDNotify)
   END_EVENT_TABLE()

for a sample application take a look at SDWrap, a simple zeroconf wrapper that lets you scan for a particular service and start an application with the found address and port. OS X and Windows binaries are provided as well.


3) how to compile

the prerequisites:

- the usual c++-compiler with headers and stuff
- wxWidgets version >= 2.8.6

to compile:
- type 'make' and cross fingers




that's pretty much it, have fun !


back to site root



something not feeling right here?
if so, please notify me . merci beaucoup...