mirror of
https://github.com/eclipse/mosquitto.git
synced 2025-05-08 16:52:13 +08:00
parent
80c7726d5c
commit
5d18962486
@ -1,4 +1,5 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -7,6 +8,11 @@
|
|||||||
|
|
||||||
static int run = -1;
|
static int run = -1;
|
||||||
|
|
||||||
|
void handle_sigint(int signal)
|
||||||
|
{
|
||||||
|
run = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void on_connect(struct mosquitto *mosq, void *obj, int rc)
|
void on_connect(struct mosquitto *mosq, void *obj, int rc)
|
||||||
{
|
{
|
||||||
if(rc){
|
if(rc){
|
||||||
@ -49,9 +55,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
rc = mosquitto_connect(mosq, "localhost", port, 60);
|
rc = mosquitto_connect(mosq, "localhost", port, 60);
|
||||||
|
|
||||||
|
signal(SIGINT, handle_sigint);
|
||||||
while(run == -1){
|
while(run == -1){
|
||||||
mosquitto_loop(mosq, -1, 1);
|
mosquitto_loop(mosq, -1, 1);
|
||||||
}
|
}
|
||||||
|
SSL_CTX_free(ssl_ctx);
|
||||||
mosquitto_destroy(mosq);
|
mosquitto_destroy(mosq);
|
||||||
|
|
||||||
mosquitto_lib_cleanup();
|
mosquitto_lib_cleanup();
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -7,6 +8,11 @@
|
|||||||
|
|
||||||
static int run = -1;
|
static int run = -1;
|
||||||
|
|
||||||
|
void handle_sigint(int signal)
|
||||||
|
{
|
||||||
|
run = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void on_connect(struct mosquitto *mosq, void *obj, int rc)
|
void on_connect(struct mosquitto *mosq, void *obj, int rc)
|
||||||
{
|
{
|
||||||
if(rc){
|
if(rc){
|
||||||
@ -53,9 +59,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
rc = mosquitto_connect(mosq, "localhost", port, 60);
|
rc = mosquitto_connect(mosq, "localhost", port, 60);
|
||||||
|
|
||||||
|
signal(SIGINT, handle_sigint);
|
||||||
while(run == -1){
|
while(run == -1){
|
||||||
mosquitto_loop(mosq, -1, 1);
|
mosquitto_loop(mosq, -1, 1);
|
||||||
}
|
}
|
||||||
|
SSL_CTX_free(ssl_ctx);
|
||||||
mosquitto_destroy(mosq);
|
mosquitto_destroy(mosq);
|
||||||
|
|
||||||
mosquitto_lib_cleanup();
|
mosquitto_lib_cleanup();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user