UPnP/UDP/Multicast Port Sharing

Posted on
Wed May 02, 2018 8:47 am
jay (support) offline
Site Admin
User avatar
Posts: 16993
Joined: Mar 19, 2008
Location: Austin, Texas

UPnP/UDP/Multicast Port Sharing

If your plugin needs to bind to a specific port to listen for UPnP and/or multicast, be sure to set the appropriate socket options so that others that may need to also listen on that port can share it with you. Here's a very simplified code snippit that illustrates it:

Code: Select all
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
sock.bind(('', 1900))

Specifically, the socket.SO_REUSEPORT option will allow others to also bind to the port. The OS will then just send each broadcast packet to each listening process.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests