上面的代码在 arduino 上的草图上运行。不知道是不是我设置的ip和服务器地址不对请大家帮忙!!!!!!
我在串行监视器上运行以运行代码。它说这是结果连接....连接失败
断开连接
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x91, 0xA2, 0xEA, 0x0D, 0x2B, 0xB1 };
byte ip[] = { 196, 10, 10, 94};
byte server[] = { 196, 10, 10,63};
EthernetClient client;
void setup()
{
Ethernet.begin(mac, ip);
Serial.begin(9600);
delay(1000);
Serial.println("connecting...");
if (client.connect(server,80)) {
Serial.println("connected");
client.print("GET http://196.10.10.63:89/calls/channel.php HTTP/1.0\n");
client.print("Host: http://196.10.10.63:89");
client.println();
}
else {
Serial.println("connection failed");
}
}
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c);
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;;)
;
}
}