Srikanth
Srikanth

Reputation: 38

Please help .Net PUSH using socket programming or WCF

I have been asked to look into the feasibility of a task regarding .NET PUSH. I have narrowed down to using two options now

Brief summary of my requirement goes like this. I have several windows client instance running on different remote machines. People can use these clients to login and subscribe to different categories of news of their choice. So whenever there is a update for a category subscribed by a user and if is login status is active then the update must to presented to him via a ticker.

Current Implementation is done via server polling every 15 minutes. Though this works fine still there are some disadvantages like A - Server Load B - Lapse in update to User (as the update to reflect on client machine will be directly dependent on interval at which client 's polls regardless of when the news was actually updated)

So we decided to enhance the system to use server push mechanism and i find the following mechanism suitable

A - Socket Programming:

Basically the plan is to create a async connection from client to server. Client will keep observing the server.

Server accepts the connection and keeps it open. ServerSocket class Subscribes to category updates and observes the same. TcpListener obj created for the clients is mapped to a dictionary object against userid eg: Dictionary.

So whenever a category update happens notify method is called were we traverse through the Clientobj from dictionary. so if a user has subscribed to category for which update happened then we stream the update to respective Client.

B - WCF:

The Second method i could think of was to use WCF callback feature as it provides duplex support. So we still subscribe to server for updates of categories of which loggedin user has subscribed. If any category update happens we call in appropriate instance using the same dictionary mechanism for eg dictionaryobject[Clientid].Callback();

I would like to know if this is an efficient method provided i cannot use aspx components? If there is an alternative way to do this server push please let me know guys. Also it would helpful if you point out advantages and disadvantages.

Thank you for your input guys,

Srikanth

Upvotes: 1

Views: 137

Answers (2)

Srikanth
Srikanth

Reputation: 38

Thank you for sharing. I have already implemented the component using WCF following are the reasons on why I chose WCF over socket programming.

1) WCF 's NETTCPBINDING feature underneath still uses Sockets for data transmission, but what made it awesome was certain predefined methods that made by life easier and saved lot of crucial development time.

2) NETTCPBINDING uses TCP as transmission medium and hence was more or less equally fast as sockets.

3) WCF is highly customizable which was one of the important reasons i went for it. I can foresee a lot of customization lining up and its only fair on my side to implement the right framework which can accommodate changes as it comes.

One of my colleague also suggested that we could use BIZTALK with Publish/Subscribe pattern to achieve the functionality. The BizTalk’s framework is already optimized for operations of similar nature. Anyways I ended up with WCF as it seemed a better fit.

Thanks

Upvotes: 1

Bogdan GROSU
Bogdan GROSU

Reputation: 36

I am working on a similar system and I can assure you you are stuck with the only two viable options.

I would say you should go for WCF if the speed of the messages pushed to the clients is not of high importance. The implementation is a "little" easier than working with the Sockets. I started first as WCF but I was not happy with the speed (which is highly important in my case).

The sockets implementation gets easier in .NET 4.5 also, but there is more work on the clients connectivity, hosting, transmission, than in WCF. However is faster and you transmit the bytes that you need to be transmitted only nothing extra.

I hope this helps.

Upvotes: 2

Related Questions