I did improve stability of ethernet-gateway in respect to reconnect:
Issue with relying on server.available() + server.write() is that it allows to connect with multiple clients. That might be fine with other protocols, but doesn't make a lot of sense as the gateway is by design connected to a single controller only. It also has issues when (re-)connecting more than 4 times in a row without doing a proper shutdown of previous connections as both WIZ5100 and UIPEthernet support only a limited (4) connections in parallel and TCP-timeouts are quite long so the gateway wouldn't notice not being connected to a valid remote-socket any more if you e.g. do a hard power down and reboot of your controller.
The change I made makes sure that whenever the controller reconnects any previous connection is properly removed by calling client.stop().
Works using Arduino-IDE 1.0.6/1.5.7 (or later) as it makes use of operator== in EthernetClient (a change I added this to EthernetClient some month ago for this very purpose...)
pgo last edited by
@ntruchsess Good job, I had to do this to WIZ5200 too, although it has bigger buffers/supports more client connections. Same situation for Iboard PRO (with onboard NET, I think 5100)