Initial hacking to make it work on windows...

This correctly implements the socket opening and closing in a cross
platform way. read/write functionality is still shaky!