Step 3: enable port in WCF

Source: Internet
Author: User

To enable the Port Sharing Service in WCF, you only need to perform the following three steps:

Enable the NET. TCP Port Sharing Service (disabled by default)

The WCF Service adopts the TCP protocol.

Set PortSharingEnabled to true.

Step 1. Enable the NET. TCP Port Sharing Service

Go to "start"> "Control Panel"> "Administrative Tools"> Service, open the "Service dialog box" as shown in, and locate "Net. TCP Port Sharing Service.

Step 2: Use the TCP protocol in the WCF Service

In TCP-based WCF communication, we use NetTcpBinding to process all the communication details, including Port Sharing.

Step 3: Set PortSharingEnabled to true

In NetTcpBinding, a special attribute PortSharingEnabled is defined to indicate whether Port Sharing is enabled.

You can configure the PortSharingEnabled attribute of NetTcpBinding to enable the port for WCF:

 
 
  1. < bindings>   
  2. < netTcpBinding>   
  3. < binding name="PortBinding" portSharingEnabled="true" /> 
  4. < /netTcpBinding> 
  5. < /bindings>  

You can also enable binding by using code.

 
 
  1. NetTcpBinding binding = new NetTcpBinding();  
  2. binding.PortSharingEnabled = true;  

This binding implicitly allows external processes (SMSvcHost.exe carrying the Net. TCP Port Sharing Service) to manage TCP sockets. The above is an introduction to all the steps for enabling the port in WCF.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.