最大只能收到3838个字节,这个范围之内都能收到完整数据,大于这个范围也能收到同样大小的文件但3838个字节之后的内容为空,很纠结,望各位大侠出手相助.这是实现采用http向服务器发信息并得到相应数据的代码:
public Stream send_Msg_0(string str)
{
send_Str = str; HttpWebRequest myHttpReq = (HttpWebRequest)WebRequest.Create(str_url);
myHttpReq.ContentType = "application/x-www-form-urlencoded"; myHttpReq.Method = "POST";
myHttpReq.BeginGetRequestStream(new AsyncCallback(PostCallBack), myHttpReq); m_object.WaitOne();
HttpWebResponse myHttpRes = (HttpWebResponse)myHttpReq.GetResponse();
Stream myStream = myHttpRes.GetResponseStream(); return myStream;
} private void PostCallBack(IAsyncResult asy)
{
HttpWebRequest objReq = (HttpWebRequest)asy.AsyncState;
Stream obj_Stream = objReq.EndGetRequestStream(asy); byte[] send_Msg_Arr = Encoding.Default.GetBytes(send_Str); obj_Stream.Write(send_Msg_Arr, 0, send_Msg_Arr.Length);
obj_Stream.Close();
m_object.Set();
}
public Stream send_Msg_0(string str)
{
send_Str = str; HttpWebRequest myHttpReq = (HttpWebRequest)WebRequest.Create(str_url);
myHttpReq.ContentType = "application/x-www-form-urlencoded"; myHttpReq.Method = "POST";
myHttpReq.BeginGetRequestStream(new AsyncCallback(PostCallBack), myHttpReq); m_object.WaitOne();
HttpWebResponse myHttpRes = (HttpWebResponse)myHttpReq.GetResponse();
Stream myStream = myHttpRes.GetResponseStream(); return myStream;
} private void PostCallBack(IAsyncResult asy)
{
HttpWebRequest objReq = (HttpWebRequest)asy.AsyncState;
Stream obj_Stream = objReq.EndGetRequestStream(asy); byte[] send_Msg_Arr = Encoding.Default.GetBytes(send_Str); obj_Stream.Write(send_Msg_Arr, 0, send_Msg_Arr.Length);
obj_Stream.Close();
m_object.Set();
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货