public void StartUdpServer() { try { StopUdpServer(); _mainUdpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); _mainUdpSocket.EnableBroadcast = true; var ip = DnsHelper.GetLocalIp(); _mainUdpSocket.Bind(new IPEndPoint(ip, 0)); } catch (Exception e) { _gameLogger.Error($"Server StartUdpServer, error: {e.Message}"); } }