Wrap errno reads in a function.

This is to give us a chance to call WSAGetLastError on windows.