Networking Reference
In-Depth Information
printf("Received: %s\n", reply);
free(reply);
sleep(1);
}
zsocket_destroy(context, request);
zctx_destroy(&context);
return 0;
}
However, we are coding in C and it already has signal-handling functions defined in
signal.h . We could do things closer to the traditional C style by including a signal
handler, as follows:
/*
Request - Reply
Send "world" in multi-parts.
server.c
*/
#include "czmq.h"
#include <signal.h>
int main (int argc, char const *argv[]) {
zctx_t* context = zctx_new();
void* socket = zsocket_new(context, ZMQ_REP);
zsocket_bind(socket, "tcp://*:5050");
signal(SIGINT, exit);
printf("Starting server...\n");
for(;;) {
char* msg = zstr_recv(socket);
 
Search MirCeyron ::




Custom Search