ChatServer Sending Commands Requesting Data

Hi i'm trying to use the example Chatserver, so that when send a string/command to the arduino if that string/command = "string sent" it sends a response back (which later i want to connect to the analogue pin to read a voltage)

The idea is we have a piece of software that will send a command over Ethernet this command can be interpreted in the chat server

the chat server receives said command processes it for example readchannel1 this then finds the voltage on channel 1 and prints it back to the client.

i cant get it to work though

Do you think it might help if you posted your program ?

Solved

this is the code below

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network.
// gateway and subnet are optional:
byte mac = {
0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF };
IPAddress ip(192,168,1, 186);
IPAddress gateway(192,168,1, 254);
IPAddress subnet(255, 255, 255, 0);

// telnet defaults to port 23
EthernetServer server(5500);
boolean alreadyConnected = false; // whether or not the client was connected previously

String inData;
//char inData;

void setup() {

// initialize the ethernet device
Ethernet.begin(mac, ip, gateway, subnet);
// start listening for clients
server.begin();
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}

Serial.print(“Chat server address:”);
Serial.println(Ethernet.localIP());
}

void loop() {
// wait for a new client:
EthernetClient client = server.available();

// when the client sends the first byte, say hello:
if (client) {
if (!alreadyConnected) {
// clead out the input buffer:
client.flush();
alreadyConnected = true;
}

if (client.available() > 0) {
// read the bytes incoming from the client:
char thisChar = client.read();
inData += thisChar;
// echo the bytes to the server as well:
Serial.write(thisChar);

// echo to the server what’s been received to confirm we have the string
if (thisChar == ‘\n’)
{
Serial.print("\nreceived:");
Serial.print(inData);
inData = “”;
}

// if the string is “help” then return message to client

if (inData == “voltage1”) {
server.write(“Channel 1 voltage Data Here”);
}
else if (inData == “voltage2”) {
server.write(“Channel 2 voltage Data Here”);
}

}

}

}