I create wifiserver using the software USR-TCP-232-Test,after unplug the cables between router and pc(server in this pc, call client.connected() still return 1。
board is amb23;
sdk is 3.1.6
arduino is 1.8.19
code is following
#include <WiFi.h>
char ssid[] = "maybetest"; // your network SSID (name)
char pass[] = "123456789"; // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0; // your network key Index number (needed only for WEP)
int status = WL_IDLE_STATUS;
IPAddress server(192,168,1,100); // numeric IP for Google (no DNS)
WiFiClient client;
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(115200);
while (!Serial) {
;
}
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue:
while (true);
}
// attempt to connect to Wifi network:
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
Serial.println("Connected to wifi");
Serial.println("\nStarting connection to server...");
// if you get a connection, report back via serial:
if (client.connect(server, 8888)) {
Serial.println("connected to server");
}
delay(100);
}
void loop() {
//idel task
delay(2000);
Serial.print(",wifi_s:");
Serial.print(WiFi.status());
Serial.print(",client_s:");
Serial.println(client.connected());
}