-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Description
Hello
Enjoying the post of @DavyLandman, I would make a small change I made in the function:
EthernetClient EthernetServer :: available ()
EthernetServer class.
The change function gives the possibility of obtaining more than one customer when using a server. Every call this having a new customer is returned, reserving for the sock that is not used until it is released when the customer receives the signal stop (), this releases the sock is worn allowing its use again.
I am doing some tests with my fork Ethernet library and the Arduino which focuses on the use of threads based on DuinOS / FreeRTOS, and would like to invite you to test my changes together with those already made, so I can also their experience.
I realized that the current library does not allow more than one client concurrently, and then I made a small change that is not yet finished and well tested, but it is helping me in my tests.
The code is not yet final, but is enough for a proposal for a new approach in obtaining the clients connected to a server.
Principal function affected:
EthernetClient EthernetServer::available()
{
accept();
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
if(Ethernet.isSocketFree(sock)){
EthernetClient client(sock);
if (EthernetClass::_server_port[sock] == _port &&
(client.status() == SnSR::ESTABLISHED ||
client.status() == SnSR::CLOSE_WAIT)) {
if (client.available()) {
// XXX: don't always pick the lowest numbered socket.
Ethernet.useSocket(sock);
return client;
}
}
}
}
return EthernetClient(MAX_SOCK_NUM);
}
File Changed:
https://github.com/carlosdelfino/Arduino/blob/ide-1.5.x/libraries/Ethernet/Ethernet.cpp
https://github.com/carlosdelfino/Arduino/blob/ide-1.5.x/libraries/Ethernet/Ethernet.h
https://github.com/carlosdelfino/Arduino/blob/ide-1.5.x/libraries/Ethernet/EthernetClient.cpp
https://github.com/carlosdelfino/Arduino/blob/ide-1.5.x/libraries/Ethernet/EthernetServer.cpp
https://github.com/carlosdelfino/Arduino/blob/ide-1.5.x/libraries/Ethernet/EthernetServer.h
ps.
@DavyLandman, I removed the previous post and created a new discussion.