Version: 1.0

Posted: 2008-07-25

Build Requirements: Xcode 3.0

Runtime Requirements: Mac OS X 10.5

View Source Code:

Download Sample (“PortMapper.zip”, 43.2K)
Download Sample (“PortMapper.dmg”, 53.6K)



Description

Bonjour (in Mac OS X 10.5 or later) provides a "port-mapping" facility, which allows a computer behind a Network Address Translator (NAT), such as a typical home router, to request a public TCP or UDP port number that can accept connections from outside. This allows the client to join peer-to-peer networks, or to provide a publicly-available service such as a Web server.

In 10.5 this facility is only available via the low-level <dnssd.h> header, and as such, using it requires familiarity with POSIX networking APIs (socket descriptors, sockaddrs, etc.) It also has no formal documentation, although there are extensive comments in the header file.

This sample code demonstrates how to use the API. It provides a complete Objective-C wrapper class that can be used as-is in Cocoa applications; or the innards of the class can be taken as snippets to use in other contexts.

Document Revision History

Date Notes
2008-07-25Demonstrates Bonjour's NAT port-mapping API, and provides a higher-level Objective-C interface to it.

Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.