Add Windows-specific socket code.

Add necessary headers, do header reordering to fit
MSVC compiling.