#!/usr/bin/python # # Small client for sending text to a socket and displaying the result. # # Licensed under the MIT license # http://opensource.org/licenses/mit-license.php # (c) 2005, Tim Potter from twisted.internet import reactor, error from twisted.internet.protocol import Protocol, ClientFactory class Send(Protocol): def connectionMade(self): self.transport.write('''POST /ContentDirectory/control HTTP/1.1\r Host: 192.168.126.1:80\r User-Agent: POSIX, UPnP/1.0, Intel MicroStack/1.0.1423\r SOAPACTION: "urn:schemas-upnp-org:service:ContentDirectory:1#Browse"\r Content-Type: text/xml\r Content-Length: 511\r \r \r \r \r \r \r 0\OnlineMedia\Internet radio\\r BrowseDirectChildren\r *\r 0\r 7\r \r \r \r \r\n''') def dataReceived(self, data): print(data) def connectionLost(self, reason): if reason.type != error.ConnectionDone: print str(reason) reactor.stop() class SendFactory(ClientFactory): protocol = Send host = '192.168.126.128' port = 5643 reactor.connectTCP(host, port, SendFactory()) reactor.run()