.Net 中的 HTTP 流
我想编写一个客户端可以使用的服务器。
因此,客户端的代码将类似于下面的内容,
req = (HttpWebRequest)WebRequest.CreateDefault(new Uri(FCookieLocation));
HttpWebResponse resp1 = (HttpWebResponse)req.GetResponse();
Stream stream = resp.GetResponseStream();
然后我想做一些类似的事情
while (true)
{
byte b = stream.ReadByte();
}
,最终服务器将耗尽数据,客户端应该知道响应已完成(也不确定如何执行此操作。
)让服务器与 WCF 数据服务(或只是普通的 WCF 服务)之类的 CRUD 服务结合使用,因为我不希望客户端访问看起来不同的 URL。
或者我别无选择,只能编写一个独立于我的 CRUD 服务的独立服务器来实现这一目标?
谢谢
I want to write a server which clients can consume.
So the code at the client will look like something like below
req = (HttpWebRequest)WebRequest.CreateDefault(new Uri(FCookieLocation));
HttpWebResponse resp1 = (HttpWebResponse)req.GetResponse();
Stream stream = resp.GetResponseStream();
I want to then do something like
while (true)
{
byte b = stream.ReadByte();
}
Eventually the server will run out of data and the client should know that the response has finished(Not sure ho to do that either.)
The preference would be to have the server be used in conjunction with a CRUD service like WCF Data Service (or just a plain WCF service) as I do not want the client to access URLs that look to distinct.
Or do I have no choice but to write an independent server that is separate from my CRUD service to achieve this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您研究过 WCF 流式传输吗?通过 Google 快速搜索,找到了这篇 MSDN 文章,其中提供了示例实现。
http://msdn.microsoft.com/en-us/library/ms751463.aspx
这不符合您的需求吗?
Have you looked into Streaming with WCF? A quick google search resulted in this MSDN article that provides a sample implementation.
http://msdn.microsoft.com/en-us/library/ms751463.aspx
Does this not fit your needs?