Hey guy, i am a student from Hong Kong, so please don't care about my suck english ![]()
I would like to read a data from telnet, and use it for "if else" statement in my program, but seem had some problem when i try to do it, i wonder if there the "client.read()" function is read the data by byte format and also store it in char by byte format too? so that the data can't use to compare with other? ![]()
Here is the code for express what i was planing to do
#include <SPI.h>
/*
* Chat Server
*
* A simple server that distributes any incoming messages to all
* connected clients. To use telnet to 10.0.0.177 and type!
*/
#include <Ethernet.h>
// network configuration. gateway and subnet are optional.
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 11, 177 };
byte gateway[] = { 192, 168, 11, 254 };
byte subnet[] = { 255, 255, 255, 0 };
char test;
// telnet defaults to port 23
Server server(23);
void setup()
{
// initialize the ethernet device
// Serial.begin(9600);
Ethernet.begin(mac, ip, gateway, subnet);
// start listening for clients
server.begin();
}
void loop()
{
Client client = server.available();
if (client) {
test = client.read();
// even i had type in 1 in telnet, the following decide not working...
if (test == 1) {
client.println("you're type in 1!\n");
} else {
client.println("you're type in 0!\n");
}
}
}