Go Down

Topic: How to reduce or timeout the time for the Ethernet W5500 when server port down (Read 242 times) previous topic - next topic

paulfer

Hi Guys

I Have a C# app running on my server, it listens on Port 7214. And, I have an arduino sketch that connects to it monotonously and sends data through.

It works just fine when the server is up and the c# app is running.

And it time(s)out fine when I disconnect the ethernet cable or disable the network adapter and it reconnects just fine then.

BUT, when I turn off the c# app, the client.connect() takes 32 seconds to timeout.

I have tried the solutions in this post: https://forum.arduino.cc/index.php?topic=291088.0

But that doesn't help for when the port / app is down.

How do I check that the port isn't available or how do I timeout the w5500 ethernet client sooner?

Here is my code to connect:

Code: [Select]
client.stop();
  if (client.connect(server, 7214) == 1)

  {
    Serial.println("Connected");

    for (int i = 0; i < MAXNUMBEROFMESSAGESINQUEUE; i++)
    {
      if (Msg[i].senttoserver == 0 )
      {
        wdt_reset();

        Msg[i].senttoserver = 1;
        Serial.print("Send to Server:"); Serial.println(i);
        client.print('u');
        client.print(unitID);
        client.println(Msg[i].contents);

      }
    }

  }
  else
  {
    Serial.println("No connection");
  }


Any ideas?

Regards
Paul

Go Up