Ethernet shield and several connections (one after another) problem

Hey guys, I do have the following problem:

I use an arduino and the ethernet shield for Connections through the Network (later, it should work through the internet). On the Arduino there is a Server running and the class I use is the "EthernetServer class.

I can easily connect to the device via port 23 by a c# Programm that uses TCPClient and all works fine, until I would like to find out if a connection got lost and until I want to connect a second time.

A first connect always works, but a second, third or fourth attemp never works. After a reboot of the arduino it works only for one connection again.

So I have the following questions:

  • How can I find out if a Connection got lost?
  • How to reset the Server then, to make sure I can do a reconnect by a Client?

Does anyone have a Code example which describes how a sever should get implemented to accept several connections?

What I do not Need to get are muliple Connections at the same time. I am only interested in one Connection after another...

The Ethernet library documentation didn`t help me or I missed something.

Best J_witt

OK, solved!

Client.available() Needs to be used like this:

    EthernetClient client = server.available();
    if (client) 
    {
        while (client.connected()) 
        {
            if (client.available()) 
            {
                char c = client.read();
}
}
}
        delay(100);
        client.stop();
        client = NULL;

Then it works as expected!

Hi bro can you give me your complete code?