How do we find the random Android wireless LAN debugging port from a Windows PC?

How do we find the random Android wireless debugging port from a Windows
PC?
Or, if we can't find the exact port, maybe we can search a set of ports?
But an official MS portqry.exe search takes forever even with the official
MS portqryui.exe GUI (ask me how I know this)?
formatting link
formatting link

What would be faster is to guess which ports Android uses, given they
always seem (in my experience) to be between ports 3#### & 4####, but
searching even just those ports using the Microsoft tools takes forever.
Hence the question...
What ports does Android 12 randomly set when connecting wirelessly to adb
via either the Wireless debugging "pair" or the "connect" adb PC commands?
*Brief history:*
While Android has forever been able to initially connect over TCP Port
5555 over USB first, and then the USB cable could have been disconnected
to mirror Android over to the PC wirelessly on your LAN...
... As of Android 12, there are fantastic new "Developer options"
for "Wireless debugging" which allow us to mirror Android over to any
PC (Mac/Windows/Linux) without ever needing a USB cable ever again!
*Brief background:*
The wonderful screen mirroring tools (Vysor, Scrcpy, Sndcpy,etc.)
connect using adb using your local Wi-Fi LAN (which is great!).
We write scripts on the PC to mirror multiple devices onto the
PC sans consoles.
Each Android device has a random port assignment for adb "pair"
for adb "connect" commands (the difference likely being encryption).
C:\> adb connect 192.168.0.2:[RANDOM-PORT]
C:\> adb pair 192.168.0.2:[RANDOM-PORT] [RANDOM-PIN]
Our scripts need a tool to TEST which random port Android 12 sets Developer
options Wireless debugging to.
We have a variety of tools but those port-scanning tools take FOREVER to
run on all possible ports.
Hence it behooves us to limit the port scan to just the ports Android 12
uses for Wireless debugging.
Examples:
C:\> portqry -n 192.168.0.2 -r 30000:40000
C:\> netstat -ano -p tcp | findstr "92.168.0.2"
C:\> adb shell "ifconfig|grep -A 1 wlan0|tail -n 1|cut -f2 -d:|cut -f1 -d' '"
C:\> adb mdns services
C:\> nmap 92.168.0.2
etc.
The need for a more efficient port scan is the reason I ask this very
specific question:
Q: What ports does Android 12 use for Developer options Wireless
debugging?
Reply to
Andy Burnelli
Loading thread data ...

Cabling-Design.com Forums website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.