Tutorials

Daytime Server (RFC867) HowTo

How To Install a Daytime Server The Easy Way on your Mac

Ever wondered how to get a simple server running on your mac? Here is how:

We use RFC867 as example protocol for our simple test server. This is the so called daytime protocol, for which the server just returns the actual time of day to a request of a client.

This daytime protocol is readily implemented by the Boost.ASIO library, that provides C++ examples for both the daytime

Supposed we have compiled the server as “boost_daytime_server” (follow the instructions given on boost.org → Getting Started), we copy it into /usr/local/bin and launch the daytime server with the following plist file “my_organization.daytime.plist” in “/Library/LaunchDaemons”:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Debug</key>
        <false/>
        <key>GroupName</key>
        <string>staff</string>
        <key>Label</key>
        <string>my_organisation.daytime</string>
        <key>OnDemand</key>
        <false/>
        <key>Program</key>
        <string>/usr/local/bin/boost_daytime_server</string>
        <key>ServiceDescription</key>
        <string>Daytime Server with Boost</string>
        <key>UserName</key>
        <string>root</string>
</dict>
</plist>

The we load the daytime service into Mac OS X:

sudo lauchctl load /Library/LaunchDaemons/my_organization.daytime.plist

A running daytime server, as described in the above boost tutorial, is available at schorsch.efi.fh-nuernberg.de. You can test your client with it:

./client schorsch.efi.fh-nuernberg.de

The output of the above command should be something like that:

Tue Apr  9 08:15:20 2013

Options: