Socket fixes for win32 compatibility