private void DoListen()
{
_udpReceiveClient = new UdpClient();//_udpPort, AddressFamily.InterNetwork);
_udpReceiveClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
_udpReceiveClient.Client.Bind(new IPEndPoint(_address, _udpPort));
IPAddress mcAddress = IPAddress.Parse("224.0.0.0");
_udpReceiveClient.JoinMulticastGroup(mcAddress);
IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, _udpPort);
while (BacNetDevice.Instance.Listen)
{
byte[] bytes = new byte[0];
try
{
bytes = _udpReceiveClient.Receive(ref groupEP);
}
catch (Exception e)
{
_logger.Error(e);
}
ParseBacNetMessage(bytes, groupEP);
}
_udpReceiveClient.Close();
}