Changes729 / ssdp

Python asyncio library for Simple Service Discovery Protocol (SSDP).

Home Page:https://en.wikipedia.org/wiki/Simple_Service_Discovery_Protocol

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python SSDP

Python asyncio library for Simple Service Discovery Protocol (SSDP).

SSDP is a UPnP sub standard. For more information see: https://en.wikipedia.org/wiki/Simple_Service_Discovery_Protocol

Setup

python3 -m pip install ssdp

Usage

import asyncio
import socket

import ssdp


class MyProtocol(ssdp.SimpleServiceDiscoveryProtocol):

    def response_received(self, response, addr):
        print(response, addr)

    def request_received(self, request, addr):
        print(request, addr)


loop = asyncio.get_event_loop()
connect = loop.create_datagram_endpoint(MyProtocol, family=socket.AF_INET)
transport, protocol = loop.run_until_complete(connect)

notify = ssdp.SSDPRequest('NOTIFY')
notify.sendto(transport, (MyProtocol.MULTICAST_ADDRESS, 1982))

try:
    loop.run_forever()
except KeyboardInterrupt:
    pass

transport.close()
loop.close()

Examples

The examples directory contains examples on how to use this library.

About

Python asyncio library for Simple Service Discovery Protocol (SSDP).

https://en.wikipedia.org/wiki/Simple_Service_Discovery_Protocol

License:MIT License


Languages

Language:Python 100.0%