ssdp server and client of upnp
Project description
ssdp_upnp
Introduction
The acticle Exploring UPnP with Python gives a realy good insight of UPNP. SSDP is one of it's implementation.
The packege includes two individual Classes, one is ssdp server, one is ssdp client. They inherits from Class threading.Thread class, thus the two class instance runs on a single thread of own. They will not block main thread. After the ssdp client find a peer with same product name, it can communicate with main thread by queue.
The logic of server is just listen a broadcast address with port 1900. If it received a "M-SEARCH" message, it will responce it's service infomation. The client just send a broadcast message with "M-SEARCH", and get server's service infomation.
The package can be used in blockchain solution where peers to find each other in LAN environment.
example
import sys
from ssdp_upnp.ssdp import Server, Client
from ssdp_upnp.ssdp import gen_logger
from queue import Queue
logger = gen_logger('sample')
if __name__ == '__main__':
try:
if sys.argv[1] == 'server':
upnpServer = Server(8048, 'blockchain', 'main')
upnpServer.start()
elif sys.argv[1] == 'client':
queue = Queue()
upnpClient = Client('blockchain', 'main', queue)
upnpClient.start()
logger.info(queue.get())
else:
logger.warning('need params server or clinet')
except Exception as e:
logger.error(e)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ssdp_upnp-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c23c71773dbc6a4deb5af140ed6ea7fbece567f2dc9fac2808a263d7f44c7eca |
|
MD5 | 8085b80c573ee71d0545fe203f108b41 |
|
BLAKE2b-256 | 238f6f27503cf4c05115b98b52c28114d3271b641340c076e8a1a841d38a405b |