We have developed a Comet Server using “libevent-2.0.19”. It was working fine on the LAN but when tried on the WAN it started to increase the file handles actually (TCP/IP sockets).
After investigating, we have found out that it is not closing the sockets on the server.
We have tried some use cases and found out that it is due to the fact that we are holding the requests to send the response when available. The default holding time is 60 seconds after that we send a TIMEOUT response.
These kind of sockets never get closed by libevent on WAN. We have verified that with special cases.
Now we have investigated the code and found a way to forcefully close the such HTTP connections within libevent. If we send an HTTP header in our response “Connection: close” libevent will surely close the connection after sending the response.
We have verified that as well.
My question here is whether this is a standard approach or we might get into some other issues with it?