//
        // Send array segment
        //
        public async Task <int> SendAsync(ArraySegment <byte> buffer, CancellationToken ct)
        {
            if (_cleanedUp)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }
            try {
                var result = await _internal.SendAsync(buffer, null, ct).ConfigureAwait(false);

                ct.ThrowIfCancellationRequested();
                return(result);
            }
            catch (OperationCanceledException) {
                throw;
            }
            catch (Exception e) {
                throw SocketException.Create("Exception during Send", e);
            }
        }
Beispiel #2
0
        //
        // Send array segment
        //
        public async Task <int> SendAsync(ArraySegment <byte> buffer, CancellationToken ct)
        {
            if (_cleanedUp)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            try {
                var result = await _internal.SendAsync(buffer, null, ct).ConfigureAwait(false);

                ct.ThrowIfCancellationRequested();
                return(result);
            }
            catch (Exception e) when(!(e is SocketException) && !(e is OperationCanceledException))
            {
                throw new SocketException("Exception during Send", e, e.GetSocketError());
            }
        }