ethernet to serial conversion

Hi, Im looking for a way to send ethernet commands to my arduino, have those ethernet commands converted to serial and parsed on the arduino. my current solution is to have an ethernet shield and read the data into the arduino but i am having a really hard time reading in the data. im asking to see if anyone knows of an easier method? i want to be able to send something simple like telnet commands via matlab over a wireless connection to my arduino.

suggestions anyone?

Thanks in advance

suggestions anyone?

Perhaps you can post the code that is not working for you.

this is what i have so far,

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

byte mac[] =     { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[]  =     {192, 168, 0, 20 };
byte gateway[] = {192, 168, 0, 254 };
byte subnet[]  = {255, 255, 255, 0 };

#define textBuffSize 3
char textBuff[textBuffSize];
int charsReceived = 0;
boolean connectFlag = 0;
unsigned long timeOfLastActivity;
unsigned long allowedConnectTime = 300000;
Server server(23);
Client client = 0;

void setup()
{
  Ethernet.begin(mac, ip, gateway, subnet);
  server.begin();
  Serial.begin(9600);
}

void loop()
{
  if (server.available() && !connectFlag) {
    connectFlag = 1;
    client = server.available();
    Serial.println("Tank Controller");
    printPrompt();
  }
  if (client.connected() && client.available()) getReceivedText();
  if(connectFlag) checkConnectionTimeout();
}

void printPrompt()
{
  timeOfLastActivity = millis();
  client.flush();
  charsReceived = 0;
}

void checkConnectionTimeout()
{
  if(millis() - timeOfLastActivity > allowedConnectTime)
  {
    client.stop();
    connectFlag = 0;
  }
}

void getReceivedText()
{
  char c;
  int charsWaiting;
  charsWaiting = client.available();
  do {
    c = client.read();
    textBuff[charsReceived] = c;
    charsReceived++;
    charsWaiting--;
  }
  while(charsReceived <= textBuffSize &&  charsWaiting > 0);
  if(c == 0x0d) {
    parseReceivedText();
    printPrompt();
  }
  if(charsReceived >= textBuffSize)
  {
    printPrompt();
  }
}

void parseReceivedText()
{
  Serial.println("He1lo");
  if( textBuff[0] != '!' ) {Serial.println("not equal");}
  if( (textBuff[1] < '"') or (textBuff[1] > '&')) {Serial.println("invalid");}

Program seems to work fine with putty, but as soon as i try it with matlab, i dont get the same results. I am finding this very tricky to debug.