Skip to content

Client.Stop slow #53

@electroremy

Description

@electroremy

Hi, I use the Ethernet lib featured by Arduino with the W5500 Arduino Official Ethernet Shield II

I notice that client.stop is slow... I found that Ethernet.socketStatus(sockindex) == SnSR::CLOSED never append.

So I change the function to do not wait until Ethernet.socketStatus(sockindex) == SnSR::CLOSED and it's works fine.

`void EthernetClient::stop() {
if (sockindex >= MAX_SOCK_NUM) return;
// attempt to close the connection gracefully (send a FIN to other side)
Ethernet.socketDisconnect(sockindex);

// Waiting for the connection to close is useless and VERY SLOW !
/*
// wait up to a second for the connection to close
unsigned long start = millis();
do {
	if (Ethernet.socketStatus(sockindex) == SnSR::CLOSED) {
		sockindex = MAX_SOCK_NUM;
		return; // exit the loop
	}
	delay(1); 
} while (millis() - start < _timeout); 
*/

delay(1); 

// if it hasn't closed, close it forcefully
Ethernet.socketClose(sockindex);
sockindex = MAX_SOCK_NUM;

}`

Also, I notice that there are several TODO in your library files (Ethernet, EthernetClient, EthernetServer, Socket, W5100...)

Does the Ethernet library is up to date on Arduino website ?

Bests regards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions