Search code examples
c#push-notificationpollinghttp-streaming

Notify windows program from WebServer


At the moment I'm writing a small program in C# for windows 7 which can send notifications over GCM (Google Cloud Messeging) to my Android smartphone. For this I send some data via POST to my WebServer which then pushes the data over GCM to my smartphone. That works great in this way but I also want to send some data to my program from my Smartphone.

My problem now is that I do not know how I can notificy my C# program from my WebServer. I thought about something like this:

Smartphone -> send Data to WebServer -> notify C# program

I do not want to use polling and the GCM client is only for android smartphones. So what do you think is the best way to notify my program that some data is avaible for it? I read something about HTTP streaming but I do not know how it works and have no idea if I can implement it with C#. Or do you have other ideas how I can solve this problem?


Solution

  • SignalR is a good shout but you should also understand the base concepts of socket programming. C# makes it really easy to open a socket and listen for messages. The Microsoft website shows you how to handle a requests synchronously here.

    Http is just a message protocol. Once you understand the protocol reading the messages is not too hard. Remember if you are receiving messages from the server it will need to know your IP address etc.