我需要创建一个仅发送多播UDP,IGMPv2数据包的UDP客户端。它永远不会监听数据包。
假设组播地址为239.180.189.25,端口为4000。
我可以这样简单地发送数据包吗?
public static class MulticastUdpClient
{
static IPEndPoint _destinationIpEndPoint;
static UdpClient _udpClient;
public static void Initialize(IPEndPoint ipEndPoint)
{
_destinationIpEndPoint = ipEndPoint;
_udpClient = new UdpClient(AddressFamily.InterNetwork);
}
public static void Send(byte[] data)
{
_udpClient.Send(data, data.Length, _destinationIpEndPoint);
}
public static void UnInitialize()
{
_udpClient.Close();
_udpClient.Dispose();
}
}