[fix]修正UdpServer在接收广播时连续启动接收的错误,在StarAgent中,此时可能收到广播包,SocketFlags是Broadcast,需要清空,否则报错“参考的对象类型不支持尝试的操作”; 无需设置SocketOptionName.PacketInformation,在ReceiveMessageFromAsync时会自动设置,并且支持ipv6;
石头 编写于 2024-10-10 00:36:00 石头 提交于 2024-10-10 00:45:43
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;
}