Created
December 8, 2012 11:28
-
-
Save hintjens/4239910 to your computer and use it in GitHub Desktop.
How to broadcast a file to a distributed network
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.