If I have a server function that is listening to a port in an infinite loop, how do I stop it? If i do ctrl+c
it terminates the process and the program does not get a chance to destroy the socket pointer. Whats the standard of dealing with this?
#include <czmq.h>int main(int argc, char **argv){ setvbuf(stdout, NULL, _IONBF, 0); zsock_t *responder = zsock_new(ZMQ_REP); int r = zsock_bind(responder, "tcp://localhost:5555"); if (r != 5555){ printf("Failed to bind\n"); } while(true){ char *msg = zstr_recv(responder); if (!strcmp(msg, "Bonjour!")){ zstr_send(responder, "Ouais!"); } free(msg); printf(".\n"); } zsock_destroy(&responder);}