12

I want to write a C program that can search Bonjour enabled devices on network.

Basically we have a Network IP Camera, it supports Bonjour protocol. I want to write API in C that can search these devices which have Bonjour enabled. Does anyone have sample code or suggestions on how should I do that?

Alan Stokes
  • 18,815
  • 3
  • 45
  • 64
Sarfraz Ahmed
  • 1,349
  • 6
  • 23
  • 43

1 Answers1

7

The following links provide some code samples, as you requested:

mDNSResponder

Quotes from mDNSPosix/ReadMe.txt:

mDNSPosix is a port of Apple's Multicast DNS and DNS Service Discovery code to Posix platforms.

Multicast DNS and DNS Service Discovery are technologies that allow you to register IP-based services and browse the network for those services.

Packing List:

The sample uses the following directories:

o mDNSCore -- A directory containing the core mDNS code. This code
is written in pure ANSI C and has proved to be very portable. Every platform needs this core protocol engine code.

o mDNSShared -- A directory containing useful code that's not core to the main protocol engine itself, but nonetheless useful, and used by
more than one (but not necessarily all) platforms.

o mDNSPosix -- The files that are specific to Posix platforms: Linux, Solaris, FreeBSD, NetBSD, OpenBSD, etc. This code will also work on
OS X, though that's not its primary purpose.

o Clients -- Example client code showing how to use the API to the
services provided by the daemon.

Using the Sample ---------------- When you compile, you will get:

o Main products for general-purpose use (e.g. on a desktop computer): - mdnsd - libmdns - nss_mdns (See nss_ReadMe.txt for important information about nss_mdns)

o Standalone products for dedicated devices (printer, network camera, etc.) - mDNSClientPosix - mDNSResponderPosix - mDNSProxyResponderPosix

o Testing and Debugging tools - dns-sd command-line tool (from the "Clients" folder) - mDNSNetMonitor - mDNSIdentify

SDWrap

ReadMe:

Quite simple wrapper app to execute some command with Zeroconf supplied addresses and ports. Uses wxWidgets and wxServDisc for service discovery...

Good luck!

Totoro
  • 158
  • 1
  • 8
  • Thanks for your kind reply. But in the given link I could not find any source code which I can use to search bonjour devices on the network. – Sarfraz Ahmed Jan 26 '12 at 04:51
  • 1
    Have you read the [ReadMe.txt](https://github.com/jevinskie/mDNSResponder/blob/2942dde61f920fbbf96ff9a3840567ebbe7cb1b6/mDNSPosix/ReadMe.txt) for your platform? Quote: "When you compile, you will get: Standalone products for dedicated devices (printer, network camera, etc.)" I did a quick read-through of the source code. It's heavily commented, and if you take the time to use the ReadMe for your specific platform as a guide I think you'll find exactly what you're looking for. – Totoro Jan 26 '12 at 11:30