私はイーサネットシールド付きのC++サーバとArduino UNOクライアントを持っています。 私の問題は、サーバーがArduino以外の切断(c#サーバー、Androidアプリケーション)を検出することです。何の理由もなく、私はArduinoソケットがまだ動いていると思う。 これは、Arduinoのコードです:Arduinoイーサネットシールドが切断を検出しない
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 4);
EthernetClient client;
void setup()
{
Serial.begin(9600);
while (!Serial)
{
;
}
if (Ethernet.begin(mac) == 0)
{
Serial.println("Failed to configure Ethernet using DHCP");
Ethernet.begin(mac, ip);
}
delay(1000);
Serial.println("connecting...");
if (client.connect("192.168.1.11", 1626))
{
Serial.println("connected");
}
else
{
Serial.println("connection failed");
}
}
void loop()
{
client.write("hello", strlen("hello")+1);
if (!client.connected())
{
Serial.println("connection failed");
client.stop();
return;
}
}
それは電源を持っていないときに、自動的にソケットの方法のArduinoを閉じることができますか?
申し訳ありませんが、それほど明確ではありません:( –
あなたには何が分かりませんか?@MartinJames –