Major structure changes and bug fixes, new example

Major restructuring of the server. Platform specific socket polling
mechanisms modularized, and a couple common functions to all three
files are stuck into util.py .