System.Net.Sockets.Socket.DoBeginSend C# (CSharp) Method

DoBeginSend() private method

private DoBeginSend ( IList buffers, SocketFlags socketFlags, OverlappedAsyncResult asyncResult ) : SocketError
buffers IList
socketFlags SocketFlags
asyncResult OverlappedAsyncResult
return SocketError
        private SocketError DoBeginSend(IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, OverlappedAsyncResult asyncResult)
        {
            if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"SRC:{LocalEndPoint} DST:{RemoteEndPoint} buffers:{buffers}");

            // Guarantee to call CheckAsyncCallOverlappedResult if we call SetUnamangedStructures with a cache in order to
            // avoid a Socket leak in case of error.
            SocketError errorCode = SocketError.SocketError;
            try
            {
                if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"asyncResult:{asyncResult}");

                errorCode = SocketPal.SendAsync(_handle, buffers, socketFlags, asyncResult);

                if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"Interop.Winsock.WSASend returns:{errorCode} returning AsyncResult:{asyncResult}");
            }
            finally
            {
                errorCode = asyncResult.CheckAsyncCallOverlappedResult(errorCode);
            }

            // Throw an appropriate SocketException if the native call fails synchronously.
            if (errorCode != SocketError.Success)
            {
                UpdateStatusAfterSocketError(errorCode);
                if (NetEventSource.IsEnabled) NetEventSource.Error(this, new SocketException((int)errorCode));
            }
            return errorCode;
        }

Same methods

Socket::DoBeginSend ( byte buffer, int offset, int size, SocketFlags socketFlags, OverlappedAsyncResult asyncResult ) : SocketError