Thursday, June 16, 2011

Silverlight: How to Receive Messages from Desktop Application

Summary
This is a simple example showing how a Silverlight application can receive messages from a standalone desktop application.


Introduction
The article is a free continuation of How to Send Message to Desktop Application where the Silverlight application sends a text message to the desktop application. Now I would like to show how the Silverlight application can receive text messages from the desktop application using TCP connection. (Actually, the example below shows the bidirectional communication between the Silverlight application and the desktop application.)

The implementation uses Eneter Messaging Framework. (Full, not limited and for non-commercial usage free version of the framework can be downloaded from http://www.eneter.net/. The online help for developers can be found at http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html.)
As mentioned in the previous article, the Silverlight communication via TCP has the following specifics:

The Silverlight framework requires the policy server.
The Silverlight framework allows only ports of range 4502 - 4532.

In addition:
The Silverlight application cannot be a TCP listener.
Therefore, if the Silverlight application wants to receive messages, it must open TCP connection to the listening desktop application and receive response messages.

SilverlightDuplexTcpConnection.gif

Read more: Codeproject