Skip to content

Not working on Windows 11 #60

Description

@manfredguentner

It only detects Renderer on the PC, not within the LAN. Not sure if there is still maintenance, but this is the only tool of that kind. I dont know why Microsoft itself is not implementing it. Please consider an update.

Since i work myself on UPnP in WSL i most probably know where the bug is. You do the M-Search on the wrong IP address . Windows has quite some internal IP addresses and interface names.

Try: powershell.exe -ExecutionPolicy Bypass -File wsl_scan.ps1

script:

try {
$sock = New-Object System.Net.Sockets.Socket([System.Net.Sockets.AddressFamily]::InterNetwork,
[System.Net.Sockets.SocketType]::Dgram,
[System.Net.Sockets.ProtocolType]::Udp)

$sock.Connect("8.8.8.8", 53)
$localEP = $sock.LocalEndPoint
$localIP = $localEP.Address.ToString()
$sock.Close()

} catch {
Write-Error "Could not determine local IP via socket method: $_"
exit 1
}

if (-not $localIP) {
Write-Error "No valid local IPv4 address found."
exit 1
}

$multicastAddress = "239.255.255.250"
$port = 1900

$request = @"
M-SEARCH * HTTP/1.1
HOST: ${multicastAddress}:${port}
MAN: "ssdp:discover"
MX: 3
ST: ssdp:all

"@

$bytes = [Text.Encoding]::ASCII.GetBytes($request)

Bind to the detected local IP

$localEP = New-Object System.Net.IPEndPoint ([System.Net.IPAddress]::Parse($localIP)), 0

$udpClient = New-Object System.Net.Sockets.UdpClient($localEP)
$udpClient.JoinMulticastGroup([System.Net.IPAddress]::Parse($multicastAddress))

$remoteEP = New-Object System.Net.IPEndPoint ([System.Net.IPAddress]::Parse($multicastAddress)), $port

Send request

$udpClient.Send($bytes, $bytes.Length, $remoteEP) | Out-Null
Write-Host "M-SEARCH sent via $localIP..."

Collect responses

$timeoutMs = 5000
$stopWatch = [System.Diagnostics.Stopwatch]::StartNew()

while ($stopWatch.ElapsedMilliseconds -lt $timeoutMs) {
if ($udpClient.Available -gt 0) {
$remote = New-Object System.Net.IPEndPoint([System.Net.IPAddress]::Any, 0)
$responseBytes = $udpClient.Receive([ref]$remote)
$response = [Text.Encoding]::ASCII.GetString($responseBytes)
Write-Host "Response from $($remote.Address):n$responsen---`n"
} else {
Start-Sleep -Milliseconds 100
}
}

$udpClient.Close()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions