Hi everyone.
I have an TCP/IP Ethernet client written in C- Sharp, and i have an Arduino TCP/IP Ethernet Server.
I have this small function, for returning data from client( in String format ).
When i sent data to Server for example: AAAA , the Serial monitor display this: AAAÿ , the last character of String will be this ÿ.( dosen't matter the length of String )
I don't know what is wrong in my code.
void loop()
{
EthernetClient client = server.available();
.
.
.
call my function
Serial.println( convertClientCommandToString( client ) );
.
.
.
}//end loop
String convertClientCommandToString( EthernetClient client ) {
String clientCommand;
clientCommand= "";
if (client.available() > 0)
{
int h = client.available()+1; // length of the command ????
for (int i = 0; i < h; i++)
{
clientCommand+= (char)client.read();
}
return clientCommand;
}
else
{
return "#";//no commands // command length == 1 ???
}
}