/** * Terminate the socket module for both in an outbound communications */ void Socket_terminate() { #if !defined(SINGLE_LISTENER) ListElement* current = NULL; #if defined(USE_POLL) struct socket_info* si = NULL; #endif FUNC_ENTRY; while (ListNextElement(s.listeners, ¤t)) { Listener* listener = (Listener*)(current->content); Socket_close_only(listener->socket); #if defined(USE_POLL) if ((si = TreeRemoveKey(s.fds_tree, &listener->socket)) == NULL) Log(LOG_WARNING, 13, "Failed to remove socket %d", listener->socket); else free(si); #endif } #else FUNC_ENTRY; Socket_close_only(s.mySocket); #endif Socket_outTerminate(); FUNC_EXIT; }
void MQTTClient_terminate(void) { FUNC_ENTRY; MQTTClient_stop(); if (initialized) { ListFree(bstate->clients); ListFree(handles); handles = NULL; Socket_outTerminate(); #if defined(HEAP_H) Heap_terminate(); #endif Log_terminate(); initialized = 0; } FUNC_EXIT; }