"David Browne" <davidbaxterbrowne no potted
me**@hotmail.com> wrote in
message news:eW**************@tk2msftngp13.phx.gbl...
"Stig-Arne Basberg" <sab(a)isystem.no> wrote in message
news:O5**************@tk2msftngp13.phx.gbl...
I am working on a project where I want to send at file from a Win CE device to a receiving PC using the HTTP protocol.
For testing purpose I made a simple test app on my PC (code below).
The problem is that only the first 8760 bytes of the file is transfered.
I have tried several times and the received file is always 8760 bytes.
I have tested with several files (10k -> 200k).
My receiving application works very well with other application. I have
transfered files over 1MB. So there must be something with my send
application.
I have checked that the size in the header message is received correctly
at the receiving end but the actual stream is to short. The size of the
stream buffer on the sending side is also correct. So it seems like there is
some problems with the "low level" transfer. Is there some setting I may have
missed?
Why are you doing an async receive? You are turning right around and
waiting for it to complete, so you're just making two threads do the work
of one.
Use simple blocking IO, and I bet you'll find the problem right away.
David
Thanks for the replay.
I am quit new to the .net framework and I don't have to much experience
working with sockets. So I am not sure I understand what you mean.
I made an other simple test (code below). But with the same result. Only
8760 bytes transfered.
public void SendFile()
{
try
{
HttpWebRequest request=(HttpWebRequest)
WebRequest.Create("http://192.168.1.10/Send/test.xml);
request.ContentType="text/xml";
request.Method = "POST";
request.Timeout = 10000;
FileStream fs = new FileStream("D:\\Temp\\test.xml", FileMode.Open,
FileAccess.Read);
request.ContentLength = fs.Length;
byte[] buf = new byte[fs.Length];
fs.Read(buf, 0, (int)fs.Length);
Stream st = request.GetRequestStream();
st.Write(buf, 0, buf.Length);
st.Flush();
st.Close();
fs.Close();
}
catch (System.Net.WebException escWeb)
{
if (escWeb.Response != null)
escWeb.Response.Close();
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}