/// <summary> Send an outgoing multicast DNS message.</summary> internal async Task Send(DNSOutgoing out_Renamed) { out_Renamed.Finish(); if (!out_Renamed.Empty) { SupportClass.PacketSupport packet = new SupportClass.PacketSupport(SupportClass.ToByteArray(out_Renamed.data), out_Renamed.off, new IPEndPoint(group, DNSConstants.MDNS_PORT)); try { DNSIncoming msg = new DNSIncoming(packet); logger.Debug("send() JmDNS out:" + msg.Print(true)); } catch (IOException e) { logger.Error("send(DNSOutgoing) - JmDNS can not parse what it sends!!!", e); } await SupportClass.UdpClientSupport.Send(socket, packet); } }
private void Socket_MessageReceived(Windows.Networking.Sockets.DatagramSocket sender, Windows.Networking.Sockets.DatagramSocketMessageReceivedEventArgs args) { uint dataLength = args.GetDataReader().UnconsumedBufferLength; byte[] result = new byte[dataLength]; args.GetDataReader().ReadBytes(result); SupportClass.PacketSupport packet = new SupportClass.PacketSupport(result, result.Length, new System.Net.IPEndPoint(System.Net.IPAddress.Parse(args.RemoteAddress.CanonicalName), int.Parse(args.RemotePort))); try { if (Enclosing_Instance.localHost.ShouldIgnorePacket(packet)) { return; } DNSIncoming msg = new DNSIncoming(packet); logger.Debug("SocketListener.run() JmDNS in:" + msg.Print(true)); lock (Enclosing_Instance.IOLock) { if (msg.Query) { if (packet.Port != DNSConstants.MDNS_PORT) { Enclosing_Instance.HandleQuery(msg, packet.Address, packet.Port); } Enclosing_Instance.HandleQuery(msg, Enclosing_Instance.Group, DNSConstants.MDNS_PORT); } else { Enclosing_Instance.HandleResponse(msg); } } } catch (IOException e) { logger.Warn("run() exception ", e); } }
private void Socket_MessageReceived(Windows.Networking.Sockets.DatagramSocket sender, Windows.Networking.Sockets.DatagramSocketMessageReceivedEventArgs args) { uint dataLength = args.GetDataReader().UnconsumedBufferLength; byte[] result = new byte[dataLength]; args.GetDataReader().ReadBytes(result); SupportClass.PacketSupport packet = new SupportClass.PacketSupport(result, result.Length, new System.Net.IPEndPoint(System.Net.IPAddress.Parse(args.RemoteAddress.CanonicalName), int.Parse(args.RemotePort))); try { if (Enclosing_Instance.localHost.ShouldIgnorePacket(packet)) return; DNSIncoming msg = new DNSIncoming(packet); logger.Debug("SocketListener.run() JmDNS in:" + msg.Print(true)); lock (Enclosing_Instance.IOLock) { if (msg.Query) { if (packet.Port != DNSConstants.MDNS_PORT) { Enclosing_Instance.HandleQuery(msg, packet.Address, packet.Port); } Enclosing_Instance.HandleQuery(msg, Enclosing_Instance.Group, DNSConstants.MDNS_PORT); } else { Enclosing_Instance.HandleResponse(msg); } } } catch (IOException e) { logger.Warn("run() exception ", e); } }
/// <summary> Send an outgoing multicast DNS message.</summary> internal async Task Send(DNSOutgoing out_Renamed) { out_Renamed.Finish(); if (!out_Renamed.Empty) { SupportClass.PacketSupport packet = new SupportClass.PacketSupport(SupportClass.ToByteArray(out_Renamed.data), out_Renamed.off, new IPEndPoint(group, DNSConstants.MDNS_PORT)); try { DNSIncoming msg = new DNSIncoming(packet); logger.Debug("send() JmDNS out:" + msg.Print(true)); } catch (IOException e) { logger.Error("send(DNSOutgoing) - JmDNS can not parse what it sends!!!", e); } await SupportClass.UdpClientSupport.Send(socket, packet); } }