WFC – Duplex Client


Here’s the code for a simplistic client to talk TCP and HTTP to the previously blogged Quote Server.

using System; using System.ServiceModel; using IndigoLib; using System.Threading; namespace IndigoClient { class Program : IQuoteCallback { static void Main(string[] args) { EndpointAddress url = new EndpointAddress(new Uri("http://localhost:8000/service")); InstanceContext callback = new InstanceContext(new Program()); using (ChannelFactory<IndigoLib.IQuoteContract> channelFactory = new ChannelFactory<IndigoLib.IQuoteContract>(callback,new WSDualHttpBinding(), url)) { IndigoLib.IQuoteContract proxy = channelFactory.CreateDuplexChannel(); proxy.GetQuote("HTPP"); Thread.Sleep(4000); channelFactory.Close(); } EndpointAddress tcp = new EndpointAddress(new Uri("net.tcp://localhost:8080/service")); using (ChannelFactory<IndigoLib.IQuoteContract> channelFactory = new ChannelFactory<IndigoLib.IQuoteContract>(callback, new NetTcpBinding(), tcp)) { IndigoLib.IQuoteContract proxy = channelFactory.CreateDuplexChannel(); proxy.GetQuote("TCP"); Thread.Sleep(4000); channelFactory.Close(); } } public void QuoteChanged(string stock, double value) { Console.WriteLine("Callback: " + stock + " " + value); } } }

~ by mdavey on November 28, 2005.

2 Responses to “WFC – Duplex Client”

  1. as-94783-sa

    I like the info you provide about bank ; cross.Good job !

  2. i’m a little bit confused. this is duplex or dual-binding client? it’s just dual/mutilple bindings, still request-response, not actually two-way communication.

    my understanding of duplex is that client can send back to server (hopefully using the same tcp connection so that it can pass through firewall as the connection was established by client), like server pushing data feed to client after price has been requested.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: