my server listen to 8083 port!!
#include <SPI.h>
#include <Ethernet.h>
//#include <string.h>
//#include <WString.h>
#include <utility/w5100.h>
// assign a MAC address for the ethernet controller.
// fill in your address here:
byte mac = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
// fill in an available IP address on your network here,
// for manual configuration:
IPAddress ip(192,168,1,55);
// fill in your Domain Name Server address here:
IPAddress myDns(192,168,1,1);
// initialize the library instance:
EthernetClient client;
//char server = “www.google.com”;
byte server = { 192, 168, 1, 3 };
unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
boolean lastConnected = false; // state of the connection last time through the main loop
const unsigned long postingInterval = 10*1000; // delay between updates, in milliseconds
int ledPin = 13;
char rfid = {“252525”};
#define STRING_BUFFER_SIZE 128
//String readString = String(100); //string for fetching data from address
char readString[STRING_BUFFER_SIZE];
int bufindex=0;
void setup() {
// start serial port:
Serial.begin(9600);
// give the ethernet module time to boot up:
pinMode(ledPin, OUTPUT);
delay(1000);
// start the Ethernet connection using a fixed IP address and DNS server:
Ethernet.begin(mac, ip);
W5100.setRetransmissionTime(0x07D0);
W5100.setRetransmissionCount(5);
//setRetransmissionTime sets the Wiznet’s timeout period, where each unit is 100us, so 0x07D0 (decimal 2000) means 200ms.
//setRetransmissionCount sets the Wiznet’s retry count. retry count of 2 or 3 makes the connect function fail really quickly.
delay(5000);
digitalWrite(ledPin, HIGH);
// print the Ethernet board/shield’s IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
}
void loop()
{
// if there’s incoming data from the net connection.
// send it out the serial port. This is for debugging
// purposes only:
if (client.available())
{
char c = client.read();
//readString.append(c);
Serial.print(c);
readString[bufindex] = c;
bufindex++;
//Serial.print(readString);
}
// if there’s no net connection, but there was one last time
// through the loop, then stop the client:
if (!client.connected() && lastConnected)
{
Serial.println();
Serial.println(“disconnecting.”);
Serial.println(“buffer.”);
//Serial.println(readString);
client.stop();
digitalWrite(ledPin, LOW);
//Serial.println(millis() - lastConnectionTime);
bufindex=0;
}
// if you’re not connected, and ten seconds have passed since
// your last connection, then connect again and send data:
if(!client.connected() && (millis() - lastConnectionTime > postingInterval))
{
httpRequest();
}
// store the state of the connection for next time through
// the loop:
lastConnected = client.connected();
}
// this method makes a HTTP connection to the server:
void httpRequest() {
// if there’s a successful connection:
if (client.connect(server, 8083)) {
digitalWrite(ledPin, HIGH);
Serial.println(“connecting…”);
// send the HTTP PUT request:
//client.println(“GET /latest.txt HTTP/1.1”);
client.print(“GET /arduino/test.php?rfid=”);
client.println(rfid);
//client.println(“Host: www.arduino.cc”);
//client.println(“User-Agent: arduino-ethernet”);
client.println(“Connection: close”);
client.println();
// note the time that the connection was made:
lastConnectionTime = millis();
}
else {
// if you couldn’t make a connection:
Serial.println(“connection failed”);
Serial.println(“disconnecting.”);
client.stop();
digitalWrite(ledPin, LOW);
}
}