Skip to content

Instantly share code, notes, and snippets.

@hintjens
Created December 8, 2012 11:28
Show Gist options
  • Select an option

  • Save hintjens/4239910 to your computer and use it in GitHub Desktop.

Select an option

Save hintjens/4239910 to your computer and use it in GitHub Desktop.
How to broadcast a file to a distributed network
#include <zre.h>
int main (int argc, char *argv [])
{
zre_interface_t *interface = zre_interface_new ();
while (true) {
zmsg_t *incoming = zre_interface_recv (interface);
if (!incoming)
break;
zmsg_dump (incoming);
zmsg_destroy (&incoming);
}
zre_interface_destroy (&interface);
return 0;
}
#include <zre.h>
int main (int argc, char *argv [])
{
if (argc < 2) {
puts ("Syntax: sender filename virtualname");
return 0;
}
printf ("Publishing %s as %s\n", argv [1], argv [2]);
zre_interface_t *interface = zre_interface_new ();
zre_interface_publish (interface, argv [1], argv [2]);
while (true) {
zmsg_t *incoming = zre_interface_recv (interface);
if (!incoming)
break;
zmsg_dump (incoming);
zmsg_destroy (&incoming);
}
zre_interface_destroy (&interface);
return 0;
}
@hintjens

hintjens commented Dec 8, 2012

Copy link
Copy Markdown
Author

File Broadcasts

Zyre connects a set of nodes on a local network (Ethernet or WiFi), handling discovery and interconnection. With a single 'publish' call you can then send a file to all nodes on the network. Nodes can join and leave at any time; new nodes will receive files already published. Zyre uses UDP for discovery, ZeroMQ for connectivity and messaging, and FileMQ for file transfer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment