This example uses the HttpRequestHandler but it seems that this easts Sockets, too.
After 128 times refresh of a page the server stoops working
I have added (according to other forum threads):
context = listener.GetContext();
…
context.Response.Close();
context.Close();
Earlier I tried this web server example (with sockets):
Her I added:
newSock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true);
to solve a similar problem with eating Sockets - this free sockets (do not linger)):
But, this I cannot do this with the HttpRequestHandler.
So, I think that both WebServer examples f lags from this Socket problem.
What to do?
I have been working myself with the httplistenerclass for weeks now. I am not seeing the eating problem on the wiz5100 stack (not cobra), and happily since on this stack we are onlylimited to 4 simultaneous sockets !
The benefits from this class are great, however many times I feel like going back to making a web server with regular server sockets for professionnal application (when the “it hardly never crashes” is not enough !). I am using the wiz5100 version of the class and I am meeting different but similar problems (plus : the getcontext is blocking, so difficult to stop if you need it: you may abort the thread holding it, but then you get memory leaks, etc). The class is not very stable on the long term. I “solve” the problem my reseting the ip stack on a regular basis,or depending on the error abort the listener and starting it again, but that does not always work.
The “WEBSERVER EXTENSION FOR FEZ COBRA” class by Wouter is really great, and hoppefuly he will be able to help you with it, as I don’t own a Cobra and httplistener behavior is different (better) on this board.
Are you getting an exception on the 129th time you are loading the page ?
After som investigations with .Net Reflector on the HttpListener etc. it is clear that these classes hides the Socket class - and this Socket is not access able.
Next, on Socket.Close() the Socket is not released because of the Linger - and it is not possible to add
(Else I think that these classes of the NETMF is useless - because they die after 128 times of user access, which is the maximum number of Sockerts allowed)
Hmm, I had my Cobra running the webserver class for days, with several requests per day. But indeed I had to reset the board when I couldn’t access the webpages anymore.
Didn’t investigated this further for now, but it might just be the issue you described.