服务端:

<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. 2015-2016-2《Java程序设计》团队博客1

    项目内容 经过一些讨论之后决定了最终的项目:简易画图板项目设计与开发 目标 制作一个能够画各种图形的画板,并能有多种颜色可以选择:输入文本时也可以选择字体:能够保存,新建,和导入图片 实现计划 十一周 ...

  2. deepin深度学习环境配置

    deepin是一个精致优美的系统.最近因为工作需要在deepin上配置深度学习环境,话不多说,接下来记录下整个的配置过程. ×××本篇文章适合对深度学习环境配置有一定了解且对deepin系统感兴趣的同 ...

  3. 菜鸟学IT之分布式文件系统

    作业来源:https://edu.cnblogs.com/campus/gzcc/GZCC-16SE1/homework/3310 1.目录操作 在HDFS中为hadoop用户创建一个用户目录(had ...

  4. php 5 与7有什么区别

    PHP 7.0使用新版的ZendEngine引擎,带来了许多新的特性,其与相比,有如下特性: 性能提升:PHP7比PHP5.0性能提升了两倍. 全面一致的64位支持. 以前的许多致命错误,现在改成抛出 ...

  5. 手把手教你 GitLab 的安装及使用

    前言 新入职公司,发现公司还在使用落后生产工具 svn,由于重度使用过 svn 和 git ,知道这两个工具之间的差异,已经在使用 git 的路上越走越远. 于是,跟上级强烈建议让我在公司推行 git ...

  6. springMvc将对象json返回时自动忽略掉对象中的特定属性的注解方式

    1.注解使用在 类名,接口头上 @JsonIgnoreProperties(value={"comid"}) //希望动态过滤掉的属性 例 @JsonIgnorePropertie ...

  7. 数据库事务和spring事务的区别

    数据库事务和spring事务 本质上其实是同一个概念,spring的事务是对数据库的事务的封装,最后本质的实现还是在数据库,假如数据库不支持事务的话,spring的事务是没有作用的.数据库的事务说简单 ...

  8. php连接mysql8报错如何解决

    php版本为5.6,连接mysql8.0时报错,但是连接其他mysql8前的版本是正常的 原因可能是mysql8默认的使用密码认证方式不一样,mysql8.0默认使用caching_sha2_pass ...

  9. WARNING:Your password has expired --linux 用户密码过期

    今天在ssh 提示  WARNING:Your password has expired 设置用户到期时间 chage -M 36000 用户名 chage -l 用户名 #查看用户信息

  10. windows 安装node.js

    安装node.js 这里我们是直接下载的编译后的zip包 地址:https://nodejs.org/en/download/ 点击下载相应的zip版本 这里我把zip包最里面一层的东西,所有内容放在 ...