[Gambas-user] HowTo a M-Search (UPnP)

Ingo bm.530502 at gmail.com
Mon Oct 30 22:02:52 CET 2017


Am 30.10.2017 um 21:45 schrieb Karl Reinl:
>>
>> Hello Tobias,
>> here is the full solution doing a M-Search based on your approach:
>>
>> Public Sub btnM_Search_Click()
>> Dim sMSearch As String
>>     $hUdp = New UdpSocket As "Socket"
>>     $hUdp.Broadcast = True
>>     $hUdp.Timeout = 500
>>     $hUdp.EndOfLine = gb.Windows
>>     $hUdp.Bind()
>>
>>     sMSearch = "M-SEARCH * HTTP/1.1\r\n"
>>     sMSearch &= "HOST: 239.255.255.250:1900\r\n"
>>     sMSearch &= "MAN: \"ssdp:discover\"\r\n"
>>     sMSearch &= "MX: 3\r\n"
>>     sMSearch &= "ST: ssdp:all\r\n\r\n"
>>     'sMSearch &= "ST: urn:schemas-upnp-org:device:MediaRenderer:1\r\n\r\n"
>>
>>     $hUdp.TargetHost = "239.255.255.250"
>>     $hUdp.TargetPort = 1900
>>     Write #$hUdp, sMSearch
>>     Debug "Request sent"
>> End
>>
>> Public Sub Socket_Read()
>>     Dim sMsg As String
>>
>>     While Not Eof($hUdp)
>>       Read #$hUdp, sMsg, Lof($hUdp)
>>     Wend
>>
>>     Debug sMsg
>> End
>>
>> Public Sub Socket_Error()
>>     Debug "Error?"
>> End
>>
>> The problem that not all devices were shown were the missing quotes in
>> "MAN: \"ssdp:discover\"\r\n".
>> I did an analysis with wireshark and saw the quotes when I used
>> gssdp-discover.
>>
>> Now it should work as expected. Could you test it?
>>
>> Thanks an regards
>> Ingo
> Salut Ingo,
>
> my 'FRITZ!Box Fon WLAN 7170' creates a 98 lines output
>
Hello Charlie,
that's great.
Thank you for testing.

Regards
Ingo


More information about the User mailing list