[...] while (cnt >= 0 && !exit_loop) { cnt = libwebsocket_service (context, 10); if (send_notification) { libwebsocket_callback_on_writable_all_protocol (&protocols[0]); send_notification = FALSE; } g_main_context_iteration (NULL, FALSE); } [...]