nend Posted December 11, 2020 Share Posted December 11, 2020 Hi, I have made small program which is collecting data from a device on my local network by using inetread. This devive uses mDNS and can be approached by using this adres "http://name.local", this works ok. Can I find what's the IPadress from this device by using Inetread, to use every it's collecting data, by using mDNS everytime it's slow and I want to use the IPadres after the first time connecting. If there is a other sollution to get the IPadres of a device using mDNS. I've search a long time for it but can't find a working sample in AutoIT how collect the IPAdres from a mDNS/Bonjour device. Link to comment Share on other sites More sharing options...
Nine Posted December 11, 2020 Share Posted December 11, 2020 Have you tried TCPNameToIP ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
nend Posted December 11, 2020 Author Share Posted December 11, 2020 I have tryd it but it won't work. TCPNameTOIP uses dns and will not work on mDNS Link to comment Share on other sites More sharing options...
pseakins Posted December 11, 2020 Share Posted December 11, 2020 I assign each device on my local network a fixed IP via static lease DHCP settings in my router. Do this, then you can just hard code the address and forget about it. Phil Seakins Link to comment Share on other sites More sharing options...
TheXman Posted December 11, 2020 Share Posted December 11, 2020 (edited) Since you are dealing with the HTTP protocol, if you aren't inextricably tied to using InetRead(), then you could easily replace InetRead with a simple CURL command. In order to retrieve the HTTP request content and/or get the remote IP address, you could run the following command and capture the stdout output: ;The following line will get the http response and the remote IP address curl -sL -w "\r\nRemote IP = %{remote_ip}\r\n" http://name.local or ;The following line will just get the remote IP address curl -sL -o nul -w "\r\nRemote IP = %{remote_ip}\r\n" http://name.local The remote IP address will be appended to the end of the output on a separate line. Once you download the 32-bit and/or 64-bit CURL for Windows executable, you can open a command console and run the commands to see the output for yourself. Then you can translate the running and capturing of the command and its output into an AutoIt script. FYI: The above curl command's parameters are:-s = run silent, no progress info-L = Follow redirects (not really necessary in your case, but useful otherwise)-o = Write the response output to the following file-w = Write the following string to the output If you need more information on CURL, read the CURL Documentation. Edited December 11, 2020 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
GokAy Posted December 11, 2020 Share Posted December 11, 2020 17 minutes ago, pseakins said: I assign each device on my local network a fixed IP via static lease DHCP settings in my router. Do this, then you can just hard code the address and forget about it. Not all routers have an option to reserve an IP address in it's DHCP server. Link to comment Share on other sites More sharing options...
nend Posted December 12, 2020 Author Share Posted December 12, 2020 (edited) @TheXman, thanks for the reply but I want it in AutoIt code. I found a link which made it possible but it has a lot of functions which I don't need so I striped the UDF and made a new one from it Link from the "DIG" from which I made this UDF I attach it if some one needs it, It's only returning the IPadres of the mDNS/bonjour device. expandcollapse popupConsoleWrite(_mDNS("http://Diskstation.local") & @CRLF) Func _mDNS($domain) Local $return_ip, $domain_convert, $mDNS_msg $domain = StringReplace($domain , "http://", "") Local $domain_array = StringSplit($domain, ".") For $i = 1 To $domain_array[0] $domain_convert = $domain_convert & Hex(BinaryLen($domain_array[$i]), 2) & StringTrimLeft(StringToBinary($domain_array[$i]), 2) Next UDPStartup() Local $mDNS_sock = UDPOpen("224.0.0.251", 5353) If @error Then UDPShutdown() SetError(1) Return "" EndIf Local $query_time = TimerInit() UDPSend($mDNS_sock, "0x5A8901000001000000000000" & $domain_convert & "0000010001") Do $mDNS_msg = UDPRecv($mDNS_sock, 512, 1) Sleep(100) Until $mDNS_msg <> "" Or TimerDiff($query_time) > 1000 UDPShutdown() For $i = 3 To 0 Step -1 $return_ip = $return_ip & Dec(StringMid(BinaryMid($mDNS_msg, BinaryLen($mDNS_msg) - $i, 1), 3)) If $i <> 0 Then $return_ip = $return_ip & "." EndIf Next Return $return_ip EndFunc Edited December 12, 2020 by nend Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now