How to read data from telnet and use it?


hey guy, student hong kong, please don't care suck english :'(

i read data telnet, , use "if else" statement in program, seem had problem when try it, wonder if there "client.read()" function read data byte format , store in char byte format too? data can't use compare other?  :'(

here code express planing do

code: [select]

#include <spi.h>

/*
* chat server
*
* simple server distributes incoming messages all
* connected clients.  to use telnet 10.0.0.177 , type!
*/

#include <ethernet.h>

// network configuration.  gateway , subnet 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 port 23
server server(23);

void setup()
{
 // initialize ethernet device
 // serial.begin(9600);
 ethernet.begin(mac, ip, gateway, subnet);

 // start listening clients
 server.begin();
}

void loop()
{
 client client = server.available();
 if (client) {
  test = client.read();
    // had type in 1 in telnet, following decide not working...
         if (test == 1) {
         client.println("you're type in 1!\n");
         } else {
         client.println("you're type in 0!\n");
         }
 }          
}
 

i know question maybe simple yours, , successful run telnet control program writing other people, know data read telnet can use decide somethings in program, don't know how can :'(


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > How to read data from telnet and use it?


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums