Moving WSAGetLastError calls closer to socket operation (#3450)
* When doing async connect on windows, connect returns `WSAEINPROGRESS`
which needs to be returned to managed code for correct handling. However
on Windows, last error gets reset before `WSAGetLastError` is called.
This fix moves all `WSAGetLastError` calls up closer to the socket
operation to make sure correct error code is returned to the managed code.
* Making sure `TcpNoDelay` is set to false for IPv4 by default and
that `DualMode` is default for IPv6.
* Making sure option value is set to 0 before calling getsockopt
because on Windows, a `BOOL` option value (eg TcpNoDelay) is returned
as a one byte value and the other bytes are left untouched which resulted
in TcpNoDelay always seemed to be true.
* Fixed so `TF_REUSE_SOCKET` is set only if `reuse` parameter is set
when disconnecting a socket.