WCF的TCP异步流是可能的? [英] wcf tcp async streamed is possible?

查看:48
本文介绍了WCF的TCP异步流是可能的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用tcp的服务,并且我的所有方法都是异步的,所以我实现了Begin/End方法(我使用C#4.0).

I have a service that use tcp, and all my methods are async so I implement the Begin/End methods (I use C# 4.0).

如果仅修改了app.confing以将传输模式设置为Streamed而不是Buffered,则在客户端中进行异步调用时,应用程序将永远等待响应.但是,如果我将传输模式更改为缓冲",则可以正常工作.

If I only modified my app.confing to set transfer mode as Streamed instead of Buffered, when I make the async call in the client, the application wait forever the response. However, if I change the transfer mode to Buffered, then it works fine.

我还注意到我需要在缓冲传输模式下使用可靠的会话,因为当我启动应用程序时,出现错误10061,目的服务主动拒绝连接.

Also I notice that I need to use a reliableSession in Buffered transfer mode because when I start the application, I get the error 10061, that the destination service refuse the connection actively.

我知道,如果我想使用流传输模式,则不需要禁用de authenticSession,所以我问是否可以将流传输模式与异步方法一起使用.

I know that if I want to use the streamed transfer mode I need no disabled de reliableSession, so I am asking if it is possible to use the streamed transfer mode with async methods.

谢谢.

我正在尝试传输5MB的文件.但是,这是一个测试,因为在生产中文件可能更大,所以我希望为将来的需求做好准备.

I am trying to transfer a 5MB file. However, this is a test, because in production, the files can be larger, so I would like to be ready for future needs.

推荐答案

答案是肯定的,您可以在异步方法上使用流传输模式.波纹管链接将带您到MSDN文章,该文章描述了为使用异步方法实现流功能而必须采取的必要步骤.

The answer is yes, you can use streamed transfer mode on your asynchronous methods. The bellow link will take you to an MSDN article which describe the necessary steps you have to take in order to achieve streaming functionality using asynchronous methods.

以下帖子应阐明您的情况: http://social.msdn.microsoft.com/Forums/zh-CN/wcf/thread/4893f3c9-2a38-462f-b49c-afa833a3760a/

The following post should clarify your situation: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/4893f3c9-2a38-462f-b49c-afa833a3760a/

另外,另一篇文章详细解释了代码示例,并说明了如何创建自托管的REST WCF服务,该服务提供了使用流模式和异步方法上载/下载大文件的功能.您可以使用基于SOAP的服务来实现相同的目的.与配置相关的事情将您的传输模式设置为流传输并增加超时值.有关完整实施示例,请检查以下链接:

Also, a different article explains in details and with code samples how you can create a self hosted REST WCF service which provides functionality for uploading/downloading large files using streaming mode and asynchronous methods. You can achieve same thing using a SOAP based service. The configuration related things are set your transfer mode to streamed and increase the timeout value. For a full implementation sample check this link: http://www.level533.com/2010/11/uploading-large-files-to-self-hosted-wcf-rest-service/

P.S:我无法在此答案中提供所有内容,否则,这将成为一篇完整的文章.

P.S: I can't provide all the content in this answer, otherwise this would become a fully fledged article.

这篇关于WCF的TCP异步流是可能的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆