Arduino to unity3d & Ipad

dear paul,

here is the code im using to send parameters to unity .. in unity app theres a tcpclient which connects to arduino and recieves these parameters and executes corresponding events.
for ex..
client.read eq 1 fire
client.read eq 2 reload etc
plz have a look and help me correct this.

regards
danneskjold

ARDUINO CODE..

#include <SPI.h>
#include <WiFi.h>

char ssid[] = "WLL-1"; // your network SSID (name)
char pass[] = "97531"; // your network password (use for WPA, or use as key for WEP)
int status = WL_IDLE_STATUS;
const int shootpin = 2;
const int reloadpin = 9;
const int switchpin = 8;
const int zoompin = 5;
int led = 13;
WiFiServer server(23);

boolean alreadyConnected = false; // whether or not the client was connected previously

void setup() {
//Initialize serial and wait for port to open:

Serial.begin(9600);
pinMode(shootpin,INPUT);
digitalWrite(shootpin,HIGH);

pinMode(reloadpin,INPUT);
digitalWrite(reloadpin,HIGH);

pinMode(switchpin,INPUT);
digitalWrite(switchpin,HIGH);

pinMode(zoompin,INPUT);
digitalWrite(zoompin,HIGH);

pinMode(led, OUTPUT);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}

// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue:
while(true);
}

// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
// start the server:
server.begin();
// you're connected now, so print out the status:
printWifiStatus();
}

void loop()
{
WiFiClient client = server.available();
if (client)
{
if (!alreadyConnected)
{
client.flush();
Serial.println("We have a new client");
client.println("Hello, client!");
alreadyConnected = true;
}
else if (digitalRead(shootpin) == LOW)
{
client.println(1);
}
else if (digitalRead(switchpin) == LOW)
{
client.println(4);
}
else if (digitalRead(reloadpin) == LOW)
{
client.println(3);
}
else if (digitalRead(zoompin) == LOW)
{
client.println(5);
}
else
{
client.println();
}
client.flush();
delay(100);
}
}

void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
digitalWrite(led, HIGH);
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);

// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}