arduino/Arduino — pull request #1489 by lestofante (2013-06-30 00:15:48+00:00)
Title: make EthernetClient trackable

Added getId() on the EthernetClient to identify it.
Added two callback function onConnect into EthernetServer and onDisconnect on EthernetClient
Added "Callback" example

This is the minimum requirement to handle multiple socket with different state.

This does not modify/impact any already-written skecth

ChatServer, that actually print "client connect" only at first client connect, because of the limitation imposed by the actual library, can be upgraded.

Other method, like getSourceIp(), getSourcePort() and getDestinationPort() in EthernetClient and getClient(int id) in EthernetServer are candidates for future request.

Instead of uint8_t EthernetClass::_is_new[MAX_SOCK_NUM] we can use a byte and some bit operation; also maybe
if (onDisconnect){
onDisconnect(*this);
}

should be put at line 134, so with clinet.getId() will give valid value on the onDisconnect callback.