Hello,
I got an error sometimes when I disable all my IP stack while trying to delete the IP object. The error code is NX_SOCKETS_BOUND.
I don't understand why I got this, i disable and delete all the ip services first though...
void net_stop_all(){ net_wifi_close(); net_http_server_stop(); net_dhcp_server_stop(); net_dhcp_client_stop(); net_ip_stop();
}
void net_wifi_close(){ if(wifi_on) { do { result = g_sf_wifi0.p_api->close(g_sf_wifi0.p_ctrl); tx_thread_sleep (50); } while(result != SSP_SUCCESS && result != SSP_ERR_NOT_OPEN); wifi_on = 0; }}
void net_http_server_stop(){ if(http_server_initialized) { result = nx_http_server_stop(&g_http_server0); tx_thread_sleep (50); result = nx_http_server_delete(&g_http_server0); tx_thread_sleep (50); memset(&g_http_server0, 0, sizeof(g_http_server0)); http_server_initialized = 0; }}
void net_dhcp_server_stop(){ if(dhcp_server_initialized) { result = nx_dhcp_server_stop(&g_dhcp_server0); tx_thread_sleep (50); result = nx_dhcp_server_delete(&g_dhcp_server0); tx_thread_sleep (50); memset(&g_dhcp_server0, 0, sizeof(g_dhcp_server0)); //result = g_wifi_stack.dhcpServerStop(g_wifi_stack_ctrl); dhcp_server_initialized = 0; }
void net_dhcp_client_stop(){ if(wdhcp_client_on) { /* Start the DHCP Client on the secondary interface. */ result = nx_dhcp_interface_stop(&g_dhcp_client1, 0); tx_thread_sleep (50); result = nx_dhcp_interface_disable(&g_dhcp_client1, 0); tx_thread_sleep (50); wdhcp_client_on = 0; } if(edhcp_client_on) { result = nx_dhcp_interface_stop(&g_dhcp_client1, 1); tx_thread_sleep (50); result = nx_dhcp_interface_disable(&g_dhcp_client1, 1); tx_thread_sleep (50); edhcp_client_on = 0; } if(dhcp_client_initialized) { result = nx_dhcp_stop(&g_dhcp_client1); tx_thread_sleep (50); result = nx_dhcp_delete(&g_dhcp_client1); tx_thread_sleep (50); memset(&g_dhcp_client1, 0, sizeof(g_dhcp_client1)); dhcp_client_initialized = 0; }}
void net_ip_stop(){ if(ip_initialized) { do{ result = nx_ip_delete(&g_ip1); tx_thread_sleep (50); memset(&g_ip1, 0, sizeof(g_ip1)); } while(result != 0); result = nx_packet_pool_delete(&g_packet_pool0); tx_thread_sleep (50); memset(&g_packet_pool0, 0, sizeof(g_packet_pool0)); ip_initialized = 0; }}
Sorry for the bad code format, i don't know how to make the code look better here :s
thanks in advance for any tips :)
Have a nice day,
Clément.
Janet, Thanks a lot for your understanding and explanation ! :) So if I do something like that it should works ? result = nx_http_server_stop(&g_http_server0); tx_thread_sleep (10); result = nx_tcp_socket_delete(&g_http_server0.nx_http_server_socket); tx_thread_sleep (10); result = nx_http_server_delete(&g_http_server0); tx_thread_sleep (10); memset(&g_http_server0, 0, sizeof(g_http_server0)); http_server_initialized = 0; result = nx_dhcp_stop(&g_dhcp_client1); tx_thread_sleep (10); result = nx_udp_socket_delete(&g_dhcp_client1.nx_dhcp_socket); tx_thread_sleep (10); result = nx_dhcp_delete(&g_dhcp_client1); tx_thread_sleep (10); memset(&g_dhcp_client1, 0, sizeof(g_dhcp_client1)); dhcp_client_initialized = 0; Is it okay like that ? Is there some socket to close with the dhcp server too ? Thanks again, CLément.
EDIT :
Tried this code, with also a socket delete for udp dhcp server socket but same problem...