Ethernet Client connections

I'm trying to get a handle on Ethernet client connections. I'm using the Ethernet.h library with the standard Ethernet shield (R3). I've seen this code is several Ethernet examples:

// if there's no net connection, but there was one last time
  // through the loop, then stop the client:
  if (!client.connected() && lastConnected) {

This doesn't seem to work very well for me, I have a sketch (you can see it here: doing an HTTP POST to and frequently this if() statement doesn't go true and doesn't disconnect.

One thing I don't really understand is the distinction between being connected and client.stop(). If client.connected() is false it means I'm not connected to the server, right? So why do I still need the client.stop() statement? I've noticed if the client.stop() is not executed the Ethernet connection can get hung up or something - meaning I try to POST, but it's not successful.

I've seen another example where client.stop() is implemented like this:

while( client.connected() ) {
  while(client.available()) {
    inChar =;
    connectLoop = 0;

  if(connectLoop > 1000) {

This seems more reliable in getting the client.stop() to execute. I'd like to better understand how all this works and what people recommend for a reliable way to implement HTTP POST.

I use that second example you mentioned. It is in both my GET and POST method examples in the playground.

It has a timeout feature that prevents the "while(client.connected())" loop from becoming an endless loop if the server stalls or the connection breaks. That is the function of the connectLoop variable.