网络库异步接口全部支持取消通知CancellationToken的传递
大石头 authored at 2023-05-16 10:30:18 智能大石头 committed at 2023-06-01 21:26:42
746.00 B
X
using NewLife.Data;

namespace NewLife.Net;

/// <summary>帧数据传输接口</summary>
/// <remarks>实现者确保数据以包的形式传输,屏蔽数据的粘包和拆包</remarks>
public interface ITransport : IDisposable
{
    /// <summary>超时</summary>
    Int32 Timeout { get; set; }

    /// <summary>打开</summary>
    Boolean Open();

    /// <summary>关闭</summary>
    Boolean Close();

    /// <summary>写入数据</summary>
    /// <param name="data">数据包</param>
    Int32 Send(Packet data);

    /// <summary>读取数据</summary>
    /// <returns></returns>
    Packet Receive();

    /// <summary>数据到达事件</summary>
    event EventHandler<ReceivedEventArgs> Received;
}