Ok I think I found a code set that was better written. This is much more portable than the one presented below. All i need to do is write a wrapper function for my serial calls and timer.
http://mbed.org/teams/mbed/code/WiflyInterface/docs/68617e1f704c/classTCPSocketServer.html