Skip Navigation

Open Transport

Feel free to read what I've written about programming Open Transport, but I can't imagine you will learn much. What follows are some notes I've made as I've gained experience working with the API.

 

My experience with the Open Transport API extends to writing a simple telnet client whose interface is exposed via a handful of AppleScript commands. Now that I have the basics, I am rewriting it with proper error-checking and other features.

References

The networking books by W. Richard Stevens have been recommended by many people, especially UNIX Network Programming (two volumes) and TCP/IP Illustrated (three volumes).

Understanding Open Transport Asset Tracking contains links to a number of other important references.
Networking Technical Notes
Networking Technical Q&As

Notes on the Functions

InitOpenTransportInContext choice of two flags depending on whether your project is an application (kInitForApplicationMask) or a shared library (kInitForExtensionMask). The second parameter is an OTClientContextPtr. Most of the sample applications I have seen pass nil for this pointer. TN 1173 says you must get the client context pointer, because you will need it pass to other functions. It also says this function serves to initialize the default application context after which you need only pass nil, and the default application context is used. That seems paradoxical to me. Richard Wesley's Carbon port of John Norstad's Newswatcher is the only source code I've seen that uses the context pointer. Until I find a reason not to, I am getting a context pointer and passing it to all the "in context" functions.

Miscellaneous

I am passing a port number to a function using an Apple Event and trying to verify that it is a number (the AppleScript compiler seems to compile anything, such as a string, even though the dictionary specifies that an integer is required). Open Transport's data type for a port is InetPort which is a UInt16. It turns out that the Apple Event manager automatically coerces the value to an integer, so you only need to check to see if the coercion failed.