winsock2 should be included before any windows.h include
MSVC compatibility
MSVC compatible unix headers
error - pointer arithmetic with an unknown size type
On windows, use CRITICAL_SECTION