#include<SPI.h>
#include<Ethernet.h>
byte mac[]={0xde,0xad,0xbe,0xef,0xfe,0xed};
//IPAddress ip(221,13,223,146);
char serverName[]="www.liu0.043.wzgrcf.com";
char temp;
byte flag;
//初始化客户端功能
EthernetClient client;
void setup() {
// put your setup code here, to run once:
//初始化串行通信
Serial.begin(9600);
if(Ethernet.begin(mac)==0){
Serial.println("failed to configuer ethernet");
// Ethernet.begin(mac,ip);
}
delay(1000);
Serial.println("connecting...");
if(client.connect(serverName,80)){
Serial.println("connected");
client.print("GET http://liu0.043.wzgrcf.com/lanewechat/update.php");
client.println(" HTTP/1.1");
client.println("Host: www.liu0.043.wzgrcf.com");
client.println("User-Agent: arduino-ethernet");
client.println("Connection: close");
client.println();
}else{
Serial.println("failed to connected");
}
}
void loop() {
// put your main code here, to run repeatedly:
if(client.available()){
char c=client.read();
Serial.print(c);
/* if(c == '#'){
temp=client.read();
Serial.println(temp);
}*/
// flag++;
/* if(flag==1){
temp=client.read();
Serial.print(temp);
*/}
// }else{
// Serial.print("error");
// }
if(!client.connected()){
Serial.println("disconnecting");
client.stop();
while(true);
}
}
|