Hey
im very new at programming arduinos but i have made the script downunder and thought about if it possible to make something similar by using TCP packets instead of udp?
If it is could someone please tell me i can read about it? i have tryed to google and look at this forum without luck.. Hope someone can help me out here

#include <SPI.h> // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h> // UDP library from: bjoern@cs.stanford.edu 12/30/2008
int led = 4;
int laser = 6;
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 5, 107);
unsigned int localPort = 7; // local port to listen on
unsigned int remotePort = 9;
// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
char ReplyBuffer[] = "The power is on"; // a string to send back
char ReplyBuffer1[] = "The power is off";
// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;
void setup() {
// start the Ethernet and UDP:
Ethernet.begin(mac,ip);
Udp.begin(localPort);
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(laser, INPUT);
}
void loop() {
int val = digitalRead(laser);
// if there's data available, read a packet
int packetSize = Udp.parsePacket();
if(packetSize)
{
Serial.print("Received packet of size ");
Serial.println(packetSize);
Serial.print("From ");
IPAddress remote = Udp.remoteIP();
for (int i =0; i < 4; i++)
{
Serial.print(remote[i], DEC);
if (i < 3)
{
Serial.print(".");
}
}
Serial.print(", port ");
Serial.println(Udp.remotePort());
// read the packet into packetBufffer
Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
Serial.println("Contents:");
Serial.println(packetBuffer);
// send a reply, to the IP address and port that sent us the packet we received
Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Udp.write(ReplyBuffer);
Udp.endPacket();
delay(10);
}
if((packetSize > 1) && (packetSize < 3))
{
if (val == HIGH)
{
digitalWrite(led, LOW);
}
else
{
digitalWrite(led, HIGH);
}
}
if((packetSize > 5) && (packetSize < 7))
{
if (val == HIGH)
{
Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Udp.write(ReplyBuffer);
Udp.endPacket();
delay(10);
}
else
{
Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Udp.write(ReplyBuffer1);
Udp.endPacket();
delay(10);
}
}
}