KeepAlive of request and response true or false

I am having some problems with errors in my http server.

[quote]
#### Exception System.Net.Sockets.SocketException - 0x00000000 (7) ####
#### Message:
#### System.Net.InputNetworkStreamWrapper::Read_HTTP_Line [IP: 015a] ####
#### System.Net.HttpListenerRequest::ParseHTTPRequest [IP: 000d] ####
#### System.Net.HttpListenerContext::get_Response [IP: 000d] ####
#### SmartHouse.NET.HttpServer+<>c__DisplayClass1::b__0 [IP: 0007] ####
#### SocketException ErrorCode = 10053
#### SocketException ErrorCode = 10053
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in System.Http.dll
#### SocketException ErrorCode = 10053
#### SocketException ErrorCode = 10053
#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (7) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::send [IP: 0000] ####
#### System.Net.Sockets.Socket::Send [IP: 0018] ####
#### System.Net.Sockets.NetworkStream::Write [IP: 0051] ####
#### System.Net.OutputNetworkStreamWrapper::Write [IP: 0017] ####
#### System.Net.HttpListenerResponse::SendHeaders [IP: 0021] ####
#### System.Net.OutputNetworkStreamWrapper::Close [IP: 000d] ####
#### System.IO.Stream::Dispose [IP: 0004] ####
#### System.Net.HttpListenerContext::Close [IP: 0006] ####
#### SmartHouse.NET.HttpServer+<>c__DisplayClass1::b__0 [IP: 0007] ####
#### SocketException ErrorCode = 10058
#### SocketException ErrorCode = 10058
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
#### SocketException ErrorCode = 10058
#### SocketException ErrorCode = 10058[/quote]
After search on net, i got to conclusion that Request.KeepAlive is true and is causing problems. I am not sure yet.
I did some reading on net, but i am not sure:
should I set KeepAlive to false or keep it to true? Why?
what about HttpListenerResponse.KeepAlive?

@ Makla - Andre is correct, even if you have KeepAlive marked as true, the client does not have to honor the request. You can also verify that the Http server class is appropriately applying the header field by connecting to your device with Telnet, and sending a generic request header, and in the server’s response, you will see a header field labeled "Connection: ". This field will have either of 2 options: ‘Keep-alive’ will request that the client socket stays open for data flow, and ‘close’ will request that the client closes the socket upon receiving all of the data as defined in the header.

My web page is a “real” page. I use jquery, pictures, css files, i am uploading files, browse SD card, reading data from SQLite, drawing javascript graphs. Every html request transfer several files.
I intend to use ajax to. But need to fix web server to support that.
My web sever is based on http://www.tinyclr.com/codeshare/entry/588
Maybe important information is, that the only user will be me. This means maximum a few request per hour and minimum a few per week.

You helped me a lot! (I did read what error 10058 and 10053 means.)
So true or false? :slight_smile:

This is an incorrect assumption, and is made by almost every developer transitioning into HTTP coding (client or server). Each file, link, image, iframe, stylesheet, javascript reference and jQuery request is handled in it’s own separate request. So, if you have a page with 4 images and a style sheet, you will receive a total of 6 requests, with their own headers etc (one for the page, one for the style sheet and one for each image) unless that file has an entry in the client’s cache. There is no descriptor to handle multiple files with a single request in RFC 2616 (HTTP/1.1). You will [em]not[/em] be flooded with all of the information you have, just the initial HTML data sheet.

So, if you go into a command prompt, type

telnet -o <your device ip> 80

Then you should be notified once it has connected, or you will see a completely blank screen, on this screen type:

GET / HTTP/1.1
Host: <device ip>
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11

Press enter after each line, and be sure to press enter TWICE for the LAST line, this will tell the server that is the end of our request, and just look for the response header, locating the entry about the connection.

I know how many different requests is made.

So. Keep alive only means, that i can load part of request, stop it and then continue. Is that true?

Web socket thing looks great. Especial because I will not have much clients.

Thanks.