Next you will want to make sure you have MDNS (or ZeroConf/Bonjour) support available to your operating system.
- For Mac OSX support should be provided automatically by Bonjour.
- For Linux, make sure Avahi is installed. For recent versions of Ubuntu this should already be installed.
- For Windows, make sure Bonjour for windows is installed.
Once the serial monitor displays the 'Listening for connections...' message, telnet to the 'candybowl.local' address. For example using a terminal session type:
After a short period of time you should see the telnet server find the IP address of the server and connect to it. You can send the same question mark command as the first server example to check the candy bowl status.
If you want to change the MDNS address of the server, just modify the call to the mdns.begin() function line in the setup() function of the sketch. By default the call looks like:
mdns.begin("candybowl", cc3000, 3600)
This means the server will listen for the 'candybowl.local' address (by convention all MDNS addresses end in '.local'). Try changing the value of the first parameter, recompiling, and uploading the sketch to have the server respond to a new address.
Also for reference the last parameter to the call specifies the time to live for the DNS record in seconds. In this case the sketch is setting a TTL of 3600 seconds, or one hour. This means your computer will cache the mapping of 'candybowl.local' to the server IP address for up to an hour. If you frequently disconnect and reconnect the server so the IP address changes, you might want to drop this down to a lower value like a few minutes. If you don't specify this third parameter, a default TTL of 1 hour will be used.
Feel free to use this simple MDNS library in your own server projects!
Continue on wrap up and look at future work you can do with this project.