Created
March 3, 2011 21:12
-
-
Save hintjens/853581 to your computer and use it in GitHub Desktop.
Example of worker API usage
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
| // | |
| // Majordomo Protocol worker example | |
| // Uses the mdwrk API to hide all MDP aspects | |
| // | |
| // Lets us 'build mdworker' and 'build all' | |
| #include "mdwrkapi.c" | |
| int main (void) | |
| { | |
| mdwrk_t *session = mdwrk_new ("tcp://localhost:5555", "echo", 1); | |
| zmsg_t *reply = NULL; | |
| while (1) { | |
| zmsg_t *request = mdwrk_recv (session, reply); | |
| zmsg_destroy (&reply); | |
| if (request == NULL) | |
| break; // Worker abandoned session | |
| reply = request; // Echo is complex... :-) | |
| } | |
| mdwrk_destroy (&session); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment