First Attempt at WiFi.Server

Nube here:

My WIFI server sketch running in a MEGA 2560 refuses to take on a C# DOT NET Client.

My C# DOT NET server/client strategy works through my Wireless Router as intended but the (with a revised port number) C# Client is just ignored by my "connected" WiFi Shield....

And yes, my wireless router maps Port 8021 to 192.168.0.21:8021

UPLOADED SKETCH OUTPUT TO THE SERIAL MONITOR:

Attempting to connect to WPA network...
SSID: 7E8E7F
WIFI Shield Firmware: 1.1.0
Connected to network
192.168.0.21

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

char ssid[] = "xxxxxx";     //  your network SSID (name) 
char pass[] = "xxxxxxxxxxxx";    // your network password
int status = WL_IDLE_STATUS;
char c;

WiFiServer server(8021);
IPAddress ip(192,168,0,21);

// the dns server ip
 IPAddress dnServer(208, 67, 220, 220);
// the router's gateway address:
 IPAddress gateway(192, 168, 0, 1);
// the subnet:
 IPAddress subnet(255, 255, 255, 0);


void setup() {
   // initialize serial:
   Serial.begin(9600);
   Serial.println("Attempting to connect to WPA network...");
   Serial.print("SSID: ");
   Serial.println(ssid);

   WiFi.config(ip, dnServer, gateway, subnet);

    Serial.print("WIFI Shield Firmware: ");
    Serial.println( WiFi.firmwareVersion());
    
   status = WiFi.begin(ssid, pass);
   if ( status != WL_CONNECTED) { 
     Serial.println("Couldn't get a wifi connection");
     while(true);
   } 
   else {
     Serial.println("Connected to network");
     IPAddress myAddress = WiFi.localIP();
     Serial.println(myAddress);
     server.begin();
   }
}

void loop() {
   // listen for incoming clients
   WiFiClient client = server.available();
   
   if (client == true) {
     Serial.println("new client");
     while( client.connected())
     {        
        if( client.available() )
        {
          // read bytes from the incoming client and write them back
          // to any clients connected to the server:
          c = client.read();
          Serial.write(c);
          server.write(c);
        }
     }
     client.stop();
   }
}

OP here....

The problem appears to have resolved itself by rebooting (PC and Arduino)... go figure :slight_smile:

To be blunt, my Arduino WiFi Shield does not seem to be vary stable. Like its not ready for a long term relationship. Works OK for a while then decides not to work ???? I have it parked within a few feet of my wireless router thinking it might be an RF signal strength problem but with little improvement.

I have upgraded the WiFi Shield firmware to V1.10 from V1.00.

The two V1.1.0 elf files, "wifi_dnld.elf" and "wifiHD.elf" were distributed with the IDE V1.8.3.

Am I playing with a full deck?

Is this as good as it gets?

TIA

Looks like my WiFi Shield is not nearly as bad as my above rant.

My first test Client s/w (as per above) was not tolerant of a single failure of an attempt to connect.

My revised Client code would continue on attempting to connect and disconnect every 60 seconds regardless of the state of the WiFi Shield.

Turns out I only had 3 failures out on 1440 attempts to connect/disconnect and they were at random times and not consecutive. Each successful connect would exchange one poll and a Arduino response then disconnect.

A failure would mean no connect with 2 (or 3) automatic retries (according to WireShark), of which I did unfairly declare a complete failure of the WiFi Shield in my stage one testing.