Connection to host lost (telnet)

Hello everyone, i’m new to Arduino, and in the attachment i uploaded a sketch which uses the ChatServer sketch to blink a LED using telnet, but when i start connecting in telnet it stays for some time then says “Connection to host lost” and it disconnects. i installed telnet client from windows features but i didn’t install the telnet server ! I need to keep the connection going on telnet, how can i do that ?

Any help would be really appreciated, thank you all in advance

Here’s my code :

#include <SPI.h>
#include <WiFi.h>

char ssid = “KheperaNet”; // your network SSID (name)
//char pass = “89bd3d40”; // your network password (use for WPA, or use as key for WEP)

int keyIndex = 0; // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

WiFiServer server(23);

boolean alreadyConnected = false; // whether or not the client was connected previously

void setup() {
//Initialize serial and wait for port to open:
pinMode(2, OUTPUT); // set the LED pin mode
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only

// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println(“WiFi shield not present”);
// don’t continue:

// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid);

// wait 10 seconds for connection:
// start the server:
// you’re connected now, so print out the status:

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

// when the client sends the first byte, say hello:
if (client) {
if (!alreadyConnected) {
// clead out the input buffer:
Serial.println(“We have a new client”);
client.println(“Hello, client!”);
alreadyConnected = true;

if (client.available() > 0) {
// read the bytes incoming from the client:
char thisChar =;

// echo the bytes to the server as well:

if (thisChar == ‘1’){
digitalWrite(2, HIGH);
} else {
if (thisChar == ‘0’){
digitalWrite(2, LOW);


void printWifiStatus() {
// print the SSID of the network you’re attached to:
Serial.print("SSID: ");

// print your WiFi shield’s IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");

// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print(“signal strength (RSSI):”);
Serial.println(" dBm");

sketch_mar21b.ino (2.42 KB)