Anonymous
Anonymous

Reputation: 649

Control number of connections at server side

I am writing embedded web server, which has only 4 hardware sockets. Sometimes Chrome which I use for testing gets into "connection refused" state for requested resources because it tries connecting more than 4 sockets concurrently. Is there any way to tell to the client (e.g. through HTTP response header) how many sockets server can handle, and/or how many free sockets device currently has?

Edit: I have just learned that I use Connection: close HTTP header for simplicity purposes, however can use Connection: keep-alive to allow several HTTP request through single connection. Not sure how it may impact the issue I described above, but what scares me that such "keep-alive" persistent connection is going to time-out within a minute => socket is totally locked for this time, while with "close" it frees immediately after data exchange.

Upvotes: 0

Views: 67

Answers (1)

user207421
user207421

Reputation: 310980

'Connection refused' tells him that. You can't send the client anything after a failure, because there is no connection to send it over. You could build in a special HTTP request to tell him how many free sockets there currently are, but that request would use up a free socket. I wouldn't do it.

Upvotes: 1

Related Questions