服务端:

<system.serviceModel>
<bindings>
<netTcpBinding>
<binding portSharingEnabled="true" name="tcpbindingConfig">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false -->
<!--<serviceMetadata httpGetEnabled="True" httpGetUrl ="http://localhost:8300/myEndpoint"/>-->
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false"/>
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="false"/>
<!--<serviceThrottling maxConcurrentCalls="1000" maxConcurrentSessions="1000" maxConcurrentInstances="1000"/>-->
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<services>
<service name="TWS.TcpService" behaviorConfiguration="serviceBehavior">
<endpoint address="" binding="netTcpBinding" contract="TWS.ITcpService" bindingConfiguration="tcpbindingConfig"/>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8299/TcpService"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>

宿主:

http://www.bubuko.com/infodetail-325542.html

客户端:

string serviceUri = "net.tcp://localhost:8298/TcpService.svc";
NetTcpBinding tcpbinding = new NetTcpBinding(SecurityMode.None);
tcpbinding.MaxReceivedMessageSize = int.MaxValue;
tcpbinding.ReaderQuotas.MaxDepth = 32;
tcpbinding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
tcpbinding.SendTimeout = TimeSpan.MaxValue;
tcpbinding.ReceiveTimeout = new TimeSpan(0, 10, 10);
EndpointAddress endpoing = new EndpointAddress(serviceUri);
using (ChannelFactory<ITcpService> chf = new ChannelFactory<ITcpService>(tcpbinding,endpoing)) {
ITcpService proxy = chf.CreateChannel();
string result=proxy.GetData(10000);
MessageBox.Show(result);

}

注意安全模式需要客户端与服务端匹配,否则会报错

System.ServiceModel.CommunicationException:“套接字连接已中止。这可能是由于处理消息时出错或远程主机超过接收超时或者潜在的网络资源问题导致的....

WCF NetTcpBinding的更多相关文章

  1. WCF NetTcpBinding 由于系统缓冲区空间不足或队列已满,不能执行套接字上的操作

    背景:WindowsService + WCF + NetTcpBinding 之前一直使用http协议模式,改为net.tcp之后隔段时间出现:由于系统缓冲区空间不足或队列已满,不能执行套接字上的操 ...

  2. 如何在IIS中承载WCF NetTcpBinding 服务

    这篇博客将介绍如何在IIS中承载NetTcpBinding的服务. 1. 首先准备服务代码. Contract namespace Contract { [ServiceContract] publi ...

  3. WCF : 如何将NetTcpBinding寄宿在IIS7上

    摘要 : 从IIS 7 开始, IIS增加了对非HTTP协议的支持. 因此, 自IIS 7之后, 可以将NetTcpBinding等非HTTP协议的Bindings直接寄宿在IIS上面. 本文将介绍如 ...

  4. WCF 非http寄宿IIS

    摘要 从IIS 7 开始, IIS增加了对非HTTP协议的支持. 因此, 自IIS 7之后, 可以将NetTcpBinding等非HTTP协议的Bindings直接寄宿在IIS上面. 本文将介绍如何在 ...

  5. 我(webabcd)的文章索引

    [最后更新:2014.08.28] 重新想象 Windows Store Apps 系列文章 重新想象 Windows 8 Store Apps 系列文章 重新想象 Windows 8 Store A ...

  6. WCF 用netTcpbinding,basicHttpBinding 传输大文件

    问题:WCF如何传输大文件 方案:主要有几种绑定方式netTcpbinding,basicHttpBinding,wsHttpbinding,设置相关的传输max消息选项,服务端和客户端都要设置,tr ...

  7. 使用NetTcpBinding,WCF服务未能被激活

    我的WCF采用的是NetTcpBinding,使用时就会报错,换成BasicHttpBinding,就一切正常 The requested service, 'net.tcp://wcf.xxxxx. ...

  8. WCF绑定netTcpBinding寄宿到IIS

    继续沿用上一篇随笔中WCF服务类库 Wettery.WcfContract.Services WCF绑定netTcpBinding寄宿到控制台应用程序 服务端 添加WCF服务应用程序 Wettery. ...

  9. WCF绑定netTcpBinding寄宿到控制台应用程序

    契约 新建一个WCF服务类库项目,在其中添加两个WCF服务:GameService,PlayerService 代码如下: [ServiceContract] public interface IGa ...

随机推荐

  1. mysql 组合聚集函数

    mysql> select * from table1; +----------+------------+-----+---------------------+ | name_new | t ...

  2. mysql下sql语句令某字段值等于原值加上一个字符串

    MYSQL在一个字段值后面加字符串,如下: member 表名 card 字段名 update member SET card = '00' || card; (postgreSQL 用 || 来连贯 ...

  3. Maven的具体使用和优点

    1.Apache软件基金会提供的项目自动化构建和项目管理软件. 基于项目对象模型(POM)概念,Maven利用一个中央信息片段能管理一个项目的构建.报告.文档等步骤. 官方网站:http://mave ...

  4. 绿色地狱 - 纽博格林赛道详解 | Nürburgring

    Nürburgring - Green Hell [統哥] 車迷人生必去一趟的德國紐柏林賽道之旅 F1赛道通常短而宽,一是为了观赏性,二是为了安全. 而Nürburgring赛道则是F1赛道的极端反面 ...

  5. Learning Context Graph for Person Search

    Learning Context Graph for Person Search 2019-06-24 09:14:03 Paper:http://openaccess.thecvf.com/cont ...

  6. XCode教程之 如何在苹果开发者平台添加设备UDID

    XCode教程之 如何在苹果开发者平台添加设备UDID.在Xcode开发中,如何在苹果开发者平台添加新的手机设备UDID,进行测试,具体如下 工具/原料 Apple Developer 方法/步骤 1 ...

  7. Linux_CentOS中Mongodb4.x 安装调试、远程管理、配置 mongodb 管理员密码

    Mongodb4.x 安装 官方文档:https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/ 1.配置 yum 源 1 ...

  8. jenkins报错Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password) 的处理

    问题背景:jenkins服务器发布代码后需要执行删除缓存的操作ssh -p222 eus_pe_devadmin@1.1.1.1 "sudo rm -rf /dev/shm/nginx/hi ...

  9. Shell流程控制语句for

    for语法格式: for 变量 in 参数列表 do 命令 done 或者 for 变量 in 参数列表 ; do 命令 done for语句流程控制图: 实例: [root@youxi1 ~]# v ...

  10. Jq如何获取并操作iframe中的元素?

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...