[Gambas-user] HowTo a M-Search (UPnP)
Tobias Boege
taboege at gmail.com
Sun Oct 29 20:10:59 CET 2017
On Sun, 29 Oct 2017, Ingo wrote:
> Am 29.10.2017 um 18:39 schrieb Tobias Boege:
> > I can't answer your question about HttpClient without looking into the
> > curl source code (maybe they support an "httpu://" schema, but I wouldn't
> > bet on it).
> Yes, that's maybe true. I have not found an example anywhere with curl?!
>
> >
> > The key to the warnings you get would be your(?) upnp.txt file which
> > is read by "curl -K", yes? The warnings about trailing garbage could
> > come from a wrong EOL marker in that file. If HTTPU is like HTTP in
> > that regard, it will use the "windows" EOL sequence "\r\n".
> I know about the CRLF. Even the last line has one. I've tried it with \n\r,
> \r\n and gb.CrLf.
> >
> > I would just use the UdpSocket from gb.net to send these requests.
> Hi Tobi,
> thanks for your reply. Do you have an approach with udpsocket?
>
See the attached script. The UdpSocket interface looks a little weird
with the manual Watch method. I don't think I've used it before, and
I don't know if the script is working, as I get no response on the
network here, but at least the code throws no error.
Regards,
Tobi
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
-------------- next part --------------
#!/usr/bin/gbs3
Use "gb.net"
Private $hUdp As UdpSocket
Public Sub Main()
$hUdp = New UdpSocket As "Socket"
$hUdp.Bind()
$hUdp.Watch(gb.Read, True)
' $hUdp.Broadcast = True ' ?
$hUdp.TargetHost = "239.255.255.250"
$hUdp.TargetPort = 1900
$hUdp.Begin()
Write #$hUdp, "M-SEARCH * HTTP/1.1\r\n"
Write #$hUdp, "HOST: 239.255.255.250:1900\r\n"
Write #$hUdp, "MAN: ssdp:discover\r\n"
Write #$hUdp, "MX: 10\r\n"
Write #$hUdp, "ST: ssdp:all\r\n"
$hUdp.Send()
Debug "Request sent"
End
Public Sub Socket_Read()
Dim sMsg As String
Debug "Received packet:"
sMsg = Read #Last, -4096
Debug sMsg
End
Public Sub Socket_Error()
Debug "Error?"
End
More information about the User
mailing list