Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6647941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:35:50+00:00 2026-05-26T00:35:50+00:00

I have a client that connects to a WCF service using a netTcpBinding .

  • 0

I have a client that connects to a WCF service using a netTcpBinding.

To connect to the service I use the following in my client:

namespace Embedded_DCC_Client
{
    public class EmbeddedClient
    {
        private ChannelFactory<IEmbeddedService> channelFactory;

        //Embedded DCC TCP Addresses
        public const String LOCAL_ADDRESS = "net.tcp://localhost:9292/EmbeddedService";
        public const String REMOTE_ADDRESS = "net.tcp://192.168.10.42:9292/EmbeddedService";

        public IEmbeddedService Proxy { get; private set; }

        public EmbeddedClient()
        {
            //Configure binding
            NetTcpBinding binding = new NetTcpBinding();
            binding.OpenTimeout = TimeSpan.MaxValue;   //infinite open timeout
            binding.CloseTimeout = TimeSpan.MaxValue;   //infinite close timeout
            binding.SendTimeout = TimeSpan.MaxValue;   //infinite send timeout
            binding.ReceiveTimeout = TimeSpan.MaxValue;   //infinite recieve timeout
            binding.Security.Mode = SecurityMode.None;  //No security mode

            //Setup the channel to the service...
            //TODO debugging use a proper IP address here, and read it from a file. Allows devs to switch between simulator (localhost) and actual embedded DCC
            channelFactory = new ChannelFactory<IEmbeddedService>(binding, new EndpointAddress(REMOTE_ADDRESS));

        }

        public void Open()
        {
            Proxy = channelFactory.CreateChannel();
        }

        public void Close()
        {
            channelFactory.Close();
        }
    }
}

For debugging I constantly switch between running the service on my local machine and a remote machine. Is there a way to grab the IP from the client’s app.config so that I do not have to recompile whenever I want to change the IP?

The client app.config is generated using MEX:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <system.serviceModel>
       <bindings>
          <netTcpBinding>
              <binding name="TCPEndPoint" closeTimeout="00:01:00" openTimeout="00:01:00"
                       receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false"
                       transferMode="Buffered" transactionProtocol="OleTransactions"
                       hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                       maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                       maxReceivedMessageSize="65536">
                   <readerQuotas maxDepth="32" maxStringContentLength="8192" 
                                 maxArrayLength="16384" maxBytesPerRead="4096" 
                                 maxNameTableCharCount="16384" />
                   <reliableSession ordered="true" inactivityTimeout="00:10:00"
                                    enabled="false" />
                   <security mode="None">
                      <transport clientCredentialType="Windows" 
                                 protectionLevel="EncryptAndSign">
                          <extendedProtectionPolicy policyEnforcement="Never" />
                      </transport>
                      <message clientCredentialType="Windows" />
                   </security>
              </binding>
          </netTcpBinding>
      </bindings>
      <client>
          <endpoint name="TCPEndPoint" 
              address="net.tcp://localhost:9292/EmbeddedService"
              binding="netTcpBinding" 
              bindingConfiguration="TCPEndPoint"
              contract="ServiceReference1.IEmbeddedService" />
      </client>
   </system.serviceModel>
</configuration>

Ideally, I would just change the IP here. How can I grab the endpoint address from here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:35:51+00:00Added an answer on May 26, 2026 at 12:35 am

    Basically, what you could do is create two client-side endpoints – one for each IP you want to connect to, and then pick which one you want in your code.

    Your client’s app.config would look something like this:

     <client>
          <endpoint name="tcpLocal" 
              address="net.tcp://localhost:9292/EmbeddedService"
              binding="netTcpBinding" 
              bindingConfiguration="TCPEndPoint"
              contract="ServiceReference1.IEmbeddedService" />
          <endpoint name="tcpRemote"
              address="net.tcp://192.168.10.42:9292/EmbeddedService"
              binding="netTcpBinding" 
              bindingConfiguration="TCPEndPoint"
              contract="ServiceReference1.IEmbeddedService" />
     </client>
    

    and then in your code, based on some criteria, you would have to use either the tcpLocal or the tcpRemote client-side endpoint definition:

    // connect to the local address
    channelFactoryLocal = new ChannelFactory<IEmbeddedService>("tcpLocal");
    
    // or connect to the remote address
    channelFactoryRemote = new ChannelFactory<IEmbeddedService>("tcpRemote");
    

    Those strings at the end denote the name= for the <client>/<endpoint> definition to use in each case. You can pick the local or the remote connection – or heck, even have both available at the same time, if you like! 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Linux/c client app that connects to a WCF web service over
It is possible to have WCF Client that connects persistantly using duplex over net.tcp
I have a mobile app webservice client that connects to a WCF webservice(on my
I have a set of webservices that I connect to using Silverlight Client. I
I have client application that uses WCF service to insert some data to backend
I have simple chat program using WCF service. One service use for server and
I have a wcf service which use wsDualHttpBinding, i get that error when i
I have a WCF service that is using a custom ServiceAuthorizationManager . The custom
I have a generic proof of concept WCF service that is using forms authentication
I need to secure a WCF service that uses netTcpBinding and connects directly with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.