Reputation: 35
In this GET request , I dont need an answer from the server , so the loop function is empty.
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip;
byte localIp[] = {192,168,1,181};
EthernetClient client;
void setup()
{
Serial.begin(9600);
Ethernet.begin(mac , localIp);
delay(1000);//give ethernet time to boot?
byte x[] = { 192,168,1,1 };//my pc , running SimpleHTTPServer (python)
client.connect(x , 8000);
delay(1000);
if(client.connected()){
Serial.println("connected"); //does never print
}
}
void loop()
{
}
The webserver of my pc does not receive any connection requests or so.
Upvotes: 0
Views: 627
Reputation: 12024
Your sample is not even compilable. Here you are fixed version.
After you connect you better close connection with client.stop() otherwise some simple servers might not be listening for a new connection and are still waiting data to come on the previous connection.
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip;
IPAddress localIp (192,168,1,181);
EthernetClient client ;
void setup()
{
Serial.begin(9600);
Ethernet.begin(mac , localIp);
char x[] = "192.168.1.1" ;//my pc , running SimpleHTTPServer (python)
client.connect(x , 8000);
if( client.connected() ){
Serial.println("connected"); //does never print
}
client.println ("Hellou world from Arduino!") ;
client.stop();
}
void loop()
{
}
Michal
Upvotes: 1