Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I haven't tried it, but you should be able to have multiple processes listen on the same UDP port bound to localhost using SO_REUSEPORT. Send broadcast UDP packets (using SO_BROADCAST) so they all get it.

From here: http://www.kohala.com/start/mcast.api.txt

"More than one process may bind to the same SOCK_DGRAM UDP port if the bind() is preceded by:

int one = 1; setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one))

"In this case, every incoming multicast or broadcast UDP datagram destined to the shared port is delivered to all sockets bound to the port. For backwards compatibility reasons, THIS DOES NOT APPLY TO INCOMING UNICAST DATAGRAMS -- unicast datagrams are never delivered to more than one socket, regardless of how many sockets are bound to the datagram's destination port."



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: