MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / check_network_status

Function check_network_status

components/net/utest/tc_sal_socket.c:90–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90static void check_network_status(void)
91{
92 LOG_I("Checking network device status...");
93
94 /* Try to create a simple socket to test network availability */
95 int test_sock = sal_socket(AF_INET, SOCK_STREAM, 0);
96 if (test_sock < 0)
97 {
98 LOG_E("Network test socket creation failed: %d", test_sock);
99 LOG_E("Network device or protocol family issue detected");
100 return;
101 }
102
103 LOG_I("Network test socket created successfully: %d", test_sock);
104 sal_closesocket(test_sock);
105
106 /* Fallback to loopback; dynamic IP via netdev may not be available */
107 safe_strcpy(local_ip, "127.0.0.1", sizeof(local_ip));
108 LOG_I("Using loopback IP address for testing: %s", local_ip);
109
110 LOG_I("Network device appears operational");
111}
112
113static int set_socket_timeout(int sock, int timeout_ms)
114{

Callers 1

utest_do_tcFunction · 0.85

Calls 3

sal_closesocketFunction · 0.85
safe_strcpyFunction · 0.85
sal_socketFunction · 0.50

Tested by

no test coverage detected