Ethernet Shield - Multiple simultaneous connections cause TCP reset I have a very inconvenient problem with a web server I'm writing for a Arduino Mega 2560 with a W5100 Ethernet Shield (with the "official" Ethernet lib). I wrote the server code and it works like a charm, BUT there is a condition, when the server won't accept all the TCP handshakes and resets the TCP connections:
When I load a big webpage, the browser (Firefox and Chrome too) asks for the .htm first, then collects the links in the file and request them all simultaneously and that's when I got the problem: 

The server gets multiple TCP connections but it only accepts the first, then dumps all the others (by TCP reset). After that the client sends them again and the problem starts again: the server accepts the first and drops the others. And so on, for example if the browser needs 3 files, it will take ~9 seconds, because of the retransmission delay. (3 + 6 seconds) Eventually the webpage will load, but a 10 second delay is not acceptable.
Is there any way to cache the requests on the Ethernet Shield or to tell the browser to wait a bit between requests or any other way, to wait a bit for the Arduino to finish the previous request?

Snippet for the server, Wireshark and Chrome network data: https://gist.github.com/anonymous/181f359b70d69e4470931204c4ec175c

Thanks for the help!

G.
I have received a request from the OP to move this to Network Engineering because it got no answers. I'm going to decline this for the moment because I doubt they will be familiar with the Arduino Ethernet shields.



The low-cost shields have a known limit on the number of connections they can handle simultaneously (no doubt limited by available RAM). From the page Arduino Ethernet Shield 2 we learn:


  It supports up to eight simultaneous socket connections. 


You don't seem to be getting that, which makes me wonder if it is a code issue. It might help to post your code. If you make code that "blocks" while handling the first connection you may not accept the other ones in a timely way, leading to a reset.

Please post a Minimal, Complete, and Verifiable example.

I did a post about a tiny web server for the Arduino which uses a state machine to handle incoming data without blocking.



You may also be able to help yourself by using the HTTP header that requests that the connection be kept open, eg.

Connection: keep-alive


That might stop the client opening new connections in quick succession.