Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to send MDNS Query over UDP to get Domain Name Pointer (PTR)?

How to send MDNS Query over UDP to get Domain Name Pointer (PTR)?

Scheduled Pinned Locked Moved C#
csharpquestiondatabasesysadmintutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jakob Farian Krarup
    wrote on last edited by
    #1

    I am currently trying to get Axis IP cameras to identify themselves via the network using C#. I've captured the packets that Axis' own tool uses and I am trying to mimic them in .NET - without success : ( Apparently the Axis program sends out a Multicast UDP/TCP packet to 224.0.0.251:5353 with the message "_axis-video_tcplocal" Here's what I captured: 224.0.0.251 MDNS Standard query PTR _axis-video._tcp.local, "QU" question I've scoured the web looking for a method to do a Domain Name Pointer lookup without any luck. Any pointers...?

    Kind regards - Jakob :cool: ********************************************* Three kinds of people in the world: - Those who can count.. - Those who can't! 10 kinds of people in the world: - Those who understand binary - Those who don't

    L 1 Reply Last reply
    0
    • J Jakob Farian Krarup

      I am currently trying to get Axis IP cameras to identify themselves via the network using C#. I've captured the packets that Axis' own tool uses and I am trying to mimic them in .NET - without success : ( Apparently the Axis program sends out a Multicast UDP/TCP packet to 224.0.0.251:5353 with the message "_axis-video_tcplocal" Here's what I captured: 224.0.0.251 MDNS Standard query PTR _axis-video._tcp.local, "QU" question I've scoured the web looking for a method to do a Domain Name Pointer lookup without any luck. Any pointers...?

      Kind regards - Jakob :cool: ********************************************* Three kinds of people in the world: - Those who can count.. - Those who can't! 10 kinds of people in the world: - Those who understand binary - Those who don't

      L Offline
      L Offline
      Leo Chapiro
      wrote on last edited by
      #2

      Hi, The way is like this: // Send request try { m_socket = new DatagramSocket(); m_socket.MessageReceived += MessageReceived; // Bind socket await m_socket.BindServiceNameAsync("5353"); HostName host = new HostName("224.0.0.251"); // Connect m_socket.JoinMulticastGroup(host); // Prepare request ... IOutputStream stream = await m_socket.GetOutputStreamAsync(host, "5353"); DataWriter writer = new DataWriter(stream); DnsQueryRequest req = new DnsQueryRequest(); byte[] b = req.BuildDnsRequest( m_service, // service to looking for ... DnDns.Enums.NsType.PTR, // PTR = 12 DnDns.Enums.NsClass.ANY, // ANY = 255 17); // User Datagram-Protokoll Udp = 17 Debug.WriteLine("Sent {0} Bytes: {1}\n", b.Length, BitConverter.ToString(b)); // ... and send it! writer.WriteBytes(b); await writer.StoreAsync(); } catch (Exception e) { Debug.WriteLine(e.Message.ToString()); }

      J 1 Reply Last reply
      0
      • L Leo Chapiro

        Hi, The way is like this: // Send request try { m_socket = new DatagramSocket(); m_socket.MessageReceived += MessageReceived; // Bind socket await m_socket.BindServiceNameAsync("5353"); HostName host = new HostName("224.0.0.251"); // Connect m_socket.JoinMulticastGroup(host); // Prepare request ... IOutputStream stream = await m_socket.GetOutputStreamAsync(host, "5353"); DataWriter writer = new DataWriter(stream); DnsQueryRequest req = new DnsQueryRequest(); byte[] b = req.BuildDnsRequest( m_service, // service to looking for ... DnDns.Enums.NsType.PTR, // PTR = 12 DnDns.Enums.NsClass.ANY, // ANY = 255 17); // User Datagram-Protokoll Udp = 17 Debug.WriteLine("Sent {0} Bytes: {1}\n", b.Length, BitConverter.ToString(b)); // ... and send it! writer.WriteBytes(b); await writer.StoreAsync(); } catch (Exception e) { Debug.WriteLine(e.Message.ToString()); }

        J Offline
        J Offline
        Jakob Farian Krarup
        wrote on last edited by
        #3

        Thanks! I had forgotten about this one again, it's been five years :-).

        Kind regards - Jakob :cool: ********************************************* Three kinds of people in the world: - Those who can count.. - Those who can't! 10 kinds of people in the world: - Those who understand binary - Those who don't

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups