﻿using System;
using System.Threading;
using System.Threading.Tasks;

namespace KafkaNet
{
    public interface IKafkaTcpSocket : IDisposable
    {
        Uri ClientUri { get; }
        Task<byte[]> ReadAsync(int readSize);
        Task<byte[]> ReadAsync(int readSize, CancellationToken cancellationToken);

        Task WriteAsync(byte[] buffer, int offset, int count);
        Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken);
    }
}

﻿using System;
using System.Threading;
using System.Threading.Tasks;

namespace KafkaNet
{
    public interface IKafkaTcpSocket : IDisposable
    {
        /// <summary>
        /// The Uri to the connected server.
        /// </summary>
        Uri ClientUri { get; }

        /// <summary>
        /// Read a certain byte array size return only when all bytes received.
        /// </summary>
        /// <param name="readSize">The size in bytes to receive from server.</param>
        /// <returns>Returns a byte[] array with the size of readSize.</returns>
        Task<byte[]> ReadAsync(int readSize);

        /// <summary>
        /// Read a certain byte array size return only when all bytes received.
        /// </summary>
        /// <param name="readSize">The size in bytes to receive from server.</param>
        /// <param name="cancellationToken">A cancellation token which will cancel the request.</param>
        /// <returns>Returns a byte[] array with the size of readSize.</returns>
        Task<byte[]> ReadAsync(int readSize, CancellationToken cancellationToken);

        /// <summary>
        /// Convenience function to write full buffer data to the server.
        /// </summary>
        /// <param name="buffer">The buffer data to send.</param>
        /// <returns>Returns Task handle to the write operation.</returns>
        Task WriteAsync(byte[] buffer);

        /// <summary>
        /// Write the buffer data to the server.
        /// </summary>
        /// <param name="buffer">The buffer data to send.</param>
        /// <param name="offset">The offset to start the read from the buffer.</param>
        /// <param name="count">The length of data to read off the buffer.</param>
        /// <returns>Returns Task handle to the write operation.</returns>
        Task WriteAsync(byte[] buffer, int offset, int count);

        /// <summary>
        /// Write the buffer data to the server.
        /// </summary>
        /// <param name="buffer">The buffer data to send.</param>
        /// <param name="offset">The offset to start the read from the buffer.</param>
        /// <param name="count">The length of data to read off the buffer.</param>
        /// <param name="cancellationToken">A cancellation token which will cancel the request.</param>
        /// <returns>Returns Task handle to the write operation.</returns>
        Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken);
    }
}

Add documentation and convenience func to interface
Add documentation and convenience func to interface
