Initial fixes to get things working

MSG_WAITALL not defined in winsock2.h on MinGW
There is no close() in winsock; correct function is closesocket()
The close() included from io.h is for files (incorrect)