【问题标题】:How to host service using UDP in WCF?如何在 WCF 中使用 UDP 托管服务?
【发布时间】:2016-12-22 23:19:55
【问题描述】:

我正在尝试在 WCF 中使用 UDP 托管服务,但我无法从该服务生成代理。我需要在 LAN 上托管服务。谁能举例说明在 WCF 中使用 UDP 的服务器和客户端?

这是我的 app.config 文件:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>

    <extensions>
      <bindingElementExtensions>
        <add name="udp_Transport" type="Microsoft.ServiceModel.Samples.UdpTransportElement, UdpTransport" />
      </bindingElementExtensions>
    </extensions>

    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
          <serviceMetadata httpGetEnabled="false"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <udpBinding>
        <binding name="UDPBinding" openTimeout="24.20:31:23.6470000" receiveTimeout="24.20:31:23.6470000" sendTimeout="24.20:31:23.6470000" maxBufferPoolSize="10000000" maxReceivedMessageSize="10000000">
          <readerQuotas maxDepth="10000000" maxStringContentLength="10000000" maxArrayLength="10000000" maxBytesPerRead="10000000" maxNameTableCharCount="10000000"/>         
        </binding>
      </udpBinding>
    </bindings>
    <services>
      <service name="UDP_Server.Service1">
        <endpoint address="soap.udp://localhost:40000/Service1/" binding="udpBinding" bindingConfiguration="UDPBinding" contract="UDP_Server.IService1">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>


        <host>
          <baseAddresses>
            <add baseAddress="soap.udp://localhost:40000/Service1/"/>
          </baseAddresses>
        </host>
      </service>
    </services>
  </system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>

【问题讨论】:

    标签: c# wcf udp wcf-binding


    【解决方案1】:

    查看以下链接: https://www.codeproject.com/Articles/757349/Multicasting-using-UdpBinding-in-WCF

    它还有一个代码示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-05
      • 1970-01-01
      • 1970-01-01
      • 2017-05-14
      • 2011-10-01
      • 1970-01-01
      • 2010-11-04
      相关资源
      最近更新 更多