Skip to content

Instantly share code, notes, and snippets.

@njh
Created April 15, 2014 16:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save njh/10746150 to your computer and use it in GitHub Desktop.
Save njh/10746150 to your computer and use it in GitHub Desktop.
// Create a new server
mosq = mosquitto_server_new();
// Configure more stuff
mosquitto_server_set_opt(MOSQUITTO_SERVER_TLS, FALSE);
// Bind server to a socket
mosquitto_server_bind(mosq, 1883);
while (!mosquitto_server_loop(mosq)) {
// Send message to all subscribers
char msg* = "My message";
mosquitto_server_publish_str(mosq, "test/foo", msg);
}
mosquitto_server_destroy(mosq);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment