On Windows socket errors are not set on errno. In the existing code we use
net_errno to access errors in network API calls. But since we mimick some network calls ourself we also need to set the Windows error when it's expected. We also need to read
net_errno instead of
errno in many places, but using POSIX values.
This MR tries to cleanup most mixed usage. There are new helper functions to avoid mistakes.