Hi Freaks
I got a problem wenn transfer large files over sockets or httplistener class. (http like)
Small files are no problem.
An error will raise when send byte per byte, 1024byte Buffer or the Complete file… Error occurs on roundabout 5000byte
HttpListener hplistener = new HttpListener("http", Settings.NetworkPort);
hplistener.Start();
int akt_position = 0;
bool is_sending = false;
while (hplistener.IsListening)
{
HttpListenerContext hcontext = hplistener.GetContext();
HttpListenerRequest hrequest = hcontext.Request;
Debug.Print("** Client Request URL: " + hrequest.RawUrl);
HttpListenerResponse hresponse = hcontext.Response;
string key = hrequest.Headers["Accept"];
string path = Settings.VolumeRoot + @ "\" + Settings.NetworkPath + @ "\" + hrequest.RawUrl.Substring(1);
byte[] msg;
if (!File.Exists(path))
{
hcontext.Response.StatusCode = (int)HttpStatusCode.NotFound;
msg = Encoding.UTF8.GetBytes("Sorry, that page does not exist");
}
else
{
hcontext.Response.StatusCode = (int)HttpStatusCode.OK;
msg = File.ReadAllBytes(path);
}
hcontext.Response.ContentLength64 = msg.Length;
using (Stream s = hcontext.Response.OutputStream)
s.Write(msg, 0, msg.Length);
}
[/Code]
Already tested with small blocks.. Same Error..
There is no out of memory exception...
the error is a socketexception error Number 10035..
The file is 13666 bytes Long.
I can Read the file complete without any Error.
Thx for any help:-)
btw my work is on my desk@ work so i will send a complete devstage with originalfiles and Detail Error messages tomorrow...
I think I had this same error, when the browser cancelled the connection while the socket was still sending. This should normally not happen unless you hit F5 a couple of times to refresh your browser.
I’m currently using this class to serve a complete directory tree of files from a SD-card without any problems. (A complete directory of files, including subdirectories, can be added to the webserver with just one call to the AddVirtualDirectory method)
It even hosts the prototype.js library which is 160kBytes