- Mac OS X 10.5 or later
- or iPhone OS 2.0 or later
- or iPhone Simulator, for iPhone OS 2.0 or later
- The MYUtilities library, which is used by MYNetwork.
How To Get It
hg clone http://bitbucket.org/snej/mynetwork/ MYNetwork
- As described above, you'll also need to download or check out MYUtilities.
- To file or view bug reports, visit the project tracker page.
How To Build It (Python)
There's a separate, and very short, page of Python instructions.
How To Build It (Objective-C / Cocoa)
With Xcode, of course. But before the first time you build MYNetwork.xcode, you'll need to tell Xcode where the MYUtilities sources are. You do this by setting up a named 'Source Tree':
- Open Xcode's Preferences panel
- Click the "Source Trees" icon at the top
- Click the "+" button to add a new item to the list
- Fill in the Setting Name as "
MYUtilities", the Display Name also as "
MYUtilities", and the Path as the absolute filesystem path to where you downloaded MYUtilities to. Do not use a "
~" (tilde) in this path! The compiler won't understand it and will give you errors.
Now you're golden. From now on you can just open MYNetwork.xcode and press the Build button.
Running the tests
Open MYNetwork/MYNetwork.xcodeproj and build the "SelfTest" target.
To run the test listener and client, enter this in one Terminal window:
cd MYNetwork BLIP/runBLIPListener
The listener should print a few lines of logging output, and then sit there waiting for a connection.
Now in another Terminal window enter:
cd MYNetwork BLIP/runBLIPClient
The client will connect to the listener and begin sending it messages, which the listener will reply to. Each of them makes sure it's getting the expected data back. If all is well, they'll keep this up indefinitely, without printing any warning messages or crashing, until you stop one of them by pressing Ctrl-C in its window.
Running the echo client/server demo
Open MYNetwork/MYNetwork.xcodeproj and build the "BLIP Echo Server" and "BLIP Echo Client" targets.
Start the server by selecting the server target and executable in Xcode, then choosing the "Run" command. It should print a few lines to the Xcode console.
Now open the MYNetwork/build/Development folder and double-click the "BLIP Echo Client" app. It will open a window with a list of servers. Select your server from the list (it's probably the only one), then type a message into the top text field and press Return. The message will be sent to the server, echoed back, and displayed in the bottom text field.
It's not very exciting, I know. (It's really just Apple's "CocoaEcho" sample app, modified to use BLIP.) I'm sure you can come up with something better.
Using MYNetwork in your own Cocoa projects
Add the source files to your own project. Use the MYNetwork.xcodeproj as an example of what source files you'll need. You can even open both projects, then drag the "MYNetwork" and "MYUtilities" groups from the MYNetwork project into your own. Make sure to uncheck the "Copy files" checkbox in the confirmation sheet.
You almost certainly don't want to add BLIPTest.m, MYUtilitiesTest_main.m, or any of the files in BLIP/Demo, to your project. Those are just for test/demo purposes.
You will also need to add the CFNetwork and Security frameworks, and the libz.dylib library to your project from the appropriate iPhone SDK directory:
Find the Frameworks in: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/CHOOSE_APPROPRIATE_SDK_HERE/System/Library/Frameworks
Find libz at: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/CHOOSE_APPROPRIATE_SDK_HERE/usr/lib/libz.dylib
The source files use C99 syntax. In your project or target build settings, find "C Language Dialect" under "GCC 4.0 - Language" and make sure it's set to either "C99" or "GNU99". If you get a lot of warnings about the "typeof" function when you build, it's because you forgot to do this.
Murky uses the
LogTo function, from MYUtilities, instead of
NSLog. This means that logging is off by default, but various types of logging can be turned on independently in a Debug build.
To enable logging in general, set the user default
YES. You can do this persistently using the
defaults write command; but it's very convenient during development to use the Arguments tab in the Xcode Executable Info panel. Just add a new entry to the arguments list, of the form "
-Log YES". Now you can check and uncheck that as desired; the change will take effect when relaunching Murky.
Once logging is enabled, you can turn on and off individual categories of logs. For any category "Something", to enable output from calls of the form
LogTo(Something, @"..."), set the user default
YES, just as above.
Note: The related
Warn( ) function always logs to the console, though.