icoman / py-MulticastServiceDiscovery

Simple multicast service discovery in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multicast Service Discovery in Python

A simple udp multicast server written in python - blog announcement.

Use this code as a start for service discovery in your projects. No license required.

Sample for creating a server:

import mcsdisc
import time

mcsd = mcsdisc.MulticastServiceDiscovery()
mcsd.registerService("key","value")
mcsd.start()
while True:
   time.sleep(1)

Sample for creating a client:

import mcsdisc
import json
import time

mcsd = mcsdisc.MulticastServiceDiscovery()
while True:
    print "\n\nDiscover:"
    L = mcsd.discover(20)
    for i in L:
       data, server = i
       d = json.loads(data.replace("'", "\""))
       print "Services from",server
       for i in d.keys():
           print i,"=",d[i]
    time.sleep(3)

Instantiate service class with:

import mcsdisc
HOST = "224.x.x.x"
PORT = yyyyy
mcsd = mcsdisc.MulticastServiceDiscovery(HOST, PORT)

A picture of service running in Linux with two servers discovered: MulticastServiceDiscovery in Linux

License-free software.

Feel free to use this software for both personal and commercial usage.

About

Simple multicast service discovery in Python


Languages

Language:Python 100.0%