views:

306

answers:

2

I am implementing a minimalistic web server application on a Microcontroller. When I have several images (or CSS/JS) on the web page, the browser creates several connections and fetches them. But the Microcontroller can not catch up with this. Is there a way to tell the browser to stop pipelining and fetch them one by one ?

Note :: "Connection: close" is already in place.

+1  A: 

I think Connection:close is exactly the wrong message. When the browser creates multiple connections, it precisely does not pipeline its requests - so ISTM that you want the browser to pipeline, instead of creating parallel connections.

So one step towards that would be to use HTTP 1.1, and keep the connection open. The browser would then reuse the TCP connection for further requests. This should allow the microcontroller to catch up.

Now, the browser might still try to create additional, parallel connections. The best reaction to that is to not accept any of these connections. So limit the number of parallel connections that you are serving (independent of client), and only read new requests when you are done reading the previous ones. In doing so, prefer to read from established connections over accepting new connections.

If you have access to the TCP stack of the controller, you might be able to tell what host a connection comes from, so you can accept connections from other browsers while limiting the number of connections from the same browser (something that you cannot do in the regular socket API).

Martin v. Löwis
I have access to the TCP stack and Yes, I will try this. Thanks...
Malkocoglu
+2  A: 

"Pipelining" is something else; it means that the user agent sends additional requests on the same connection although the first one didn't complete yet (see http://greenbytes.de/tech/webdav/rfc2616.html#pipelining).

"Connection: close" doesn't seem to be relevant; that being said: is there a reason why you don't want the connection reused?

With respect to your question: no, I don't think you can prevent clients from doing that. Did you try limiting the maximum number of open connections on your server?

Julian Reschke
There is already a limit on the number of open connections. The problem was when I was processing the request, the browser sent the SYN packets for other connections and this flooded the very small hardware buffer and this lead to other problems. I did not want the connection reused because the connection does not have a state as we know on bigger platforms. Maybe I will try to support pipeline. Thanks for answering...
Malkocoglu