Now that we're using krb5_net_write() with non-blocking sockets in
ipropd_master, we MUST correctly account for partial writes.
Therefore, roken net_write() called from krb5_net_write() now
returns the number of bytes written when the socket error was
EWOULDBLOCK (or EAGAIN).
Also, fix potential issue on Windows, where errno was used instead
of rk_SOCKET_ERRNO whether or not we used _write() or send().
Sockets and file descriptors are not interchangeable on Windows. The
test for checking whether a given value is a socket or an FD was
broken for the case where WinSock was not initialized to begin with.
When using WinSock, a socket is not a file descriptor and does not
interoperate with read()/write(). File descriptors do not work with
send()/recv(). However, for net_read() and net_write(), we don't know
whether we are dealing with a socket or a file descriptor. So try
one, and if it fails, try the other.
This is an ugly hack until we clean up the users of this API so it
doesn't use sockets and fds interchangably.