Helios.Channels.Sockets.TcpSocketChannel.DoWriteBytes C# (CSharp) 메소드

DoWriteBytes() 보호된 메소드

protected DoWriteBytes ( IByteBuf buf ) : int
buf IByteBuf
리턴 int
        protected override int DoWriteBytes(IByteBuf buf)
        {
            if (!buf.HasArray)
            {
                throw new NotImplementedException("Only IByteBuffer implementations backed by array are supported.");
            }

            SocketError errorCode;
            var sent = Socket.Send(buf.Array, buf.ArrayOffset + buf.ReaderIndex, buf.ReadableBytes, SocketFlags.None,
                out errorCode);

            if (errorCode != SocketError.Success && errorCode != SocketError.WouldBlock)
            {
                throw new SocketException((int) errorCode);
            }

            if (sent > 0)
            {
                buf.SetReaderIndex(buf.ReaderIndex + sent);
            }

            return sent;
        }