Fixing windows sockets stuff

I will have to tweak and test the linux stuff later.