Networking-for-Arduino / EthernetENC

Ethernet library for ENC28J60. This is a modern version of the UIPEthernet library. EthernetENC library is compatible with all Arduino architectures with Arduino SPI library with transactions support. Only include EthernetENC.h instead of Ethernet.h
127 stars 28 forks source link

client.stop() not sending FIN packet to peer device? #62

Closed rac234 closed 3 months ago

rac234 commented 3 months ago

I am using the V2.0.4 EthernetENC library with an MKR 1500 NB and ENC28J60 Ethernet board connected to a Windows PC through a router. DHCP, connection to peer and sending and receiving data is working. If I call client.stop() the Arduino device closes its connection. However, the PC program does not indicate a closed connection, in fact thinks the connection is still open. When data is sent by the Windows program, it finds the Arduino socket is closed so indicates the connection is closed. Checking the Ethernet packet transactions with WireShark shows no FIN packet being sent by the Arduino. Here is a code snippet.

// if you get a connection, report back via serial: if (client.connect(server, port)) { Serial.print("connected to server:"); Serial.println(server); } else { // if you didn't get a connection to the server: Serial.println("connection failed"); } }

void loop() { if (client.connected()) { client.print("Hello from Arduino."); client.stop(); } while (true) { delay(1); } }

Here is the Wireshark capture. There is no FIN packet sent by the Arduino IP 192.168.1.137. image Also I cannot see any attempt in the EthernetENC code to send the FIN packet on stop() - but I might have missed it.

JAndrassy commented 3 months ago

add Ethernet.maintain() into the endless loop. https://github.com/JAndrassy/EthernetENC/wiki/Limitations