tags:

views:

176

answers:

5

Hello guys,

Am developing a desktop app that will serve as message notifier, just like yahoo messenger and Gmail notifier does. All i want is that when a message is sent to a particular account, the php script would send message to a particular ip:port of the desktop application.

Any help

+4  A: 

Expose web service (ex. WCF service with basicHTTP) in your desktop application and send messages using for example SOAPClient from PHP to your desktop app. Web services are very good for intolerability issues. Of course you can use pure socket solution, but I would suggest web services.

RESTFul services are also a good option.

EDIT : PHP calling .NET – PHP to WCF communication.

Incognito
Rest = Easier, Soap = Professionalism, +1
RobertPitt
please some code, please
Smith
You need some code for which part. To develop WCF service or how to call it from PHP ? Check the edit to the answer. There you can see full example.
Incognito
AM using vs2005, which does no support windows communication foundation (wfc). I'll be listening on port 80, 21 or any know good port. Please if you can give me the code for the php soap.
Smith
You can use .NET remoting in that case. For PHP code check the link above in answer. You just need to use SOAPclient class in PHP.
Incognito
i will have over 100 clients, and pinging d server is not really ok. i just want to listen at ip:port, and the php connects and sends message when ever a client gets message
Smith
+2  A: 

I don't think you will be able to sent message from php to Win application. There can be two solution

  1. You create a Wcf self hosted service within your win app which will be exposed on a particular port to which your php script will make a request to notify.
  2. Ping a php page at particular intervals.
Asp Net
Can you give me a kick start code?
Smith
am using vs2005, i don't have WCF
Smith
Won't option 2 work for you? It will be more simpler.
Asp Net
i will have over 100 clients, and pinging d server is not really ok. i just want to listen at ip:port, and the php connects and sends message when evr a client gets message
Smith
+2  A: 

You might consider going the other way - expose a REST web service from your PHP code, and periodically query that service from your client appliation.

Justin Ethier
pleae give me some code that implement this
Smith
+3  A: 

I'm assuming (perhaps incorrectly) that this is a PHP script on a webserver.

If that's the case, doing it the other way around is much easier. By that I mean add another script that C# can call and receive instructions/data from. I suggest you use a nice slimline format like JSON but anything will do as long as you can process it at each end.

Oli
how do i listen on the ip:port, in c#
Smith
I'm saying you shouldn't do that. I'm saying you should connect to the PHP server from your C# app using System.Net.HttpWebRequest on a timed basis (say, every 5 seconds)
Oli
thanks for replying, but the app will br use by many people, are you sure this method will not stress the server?. Also can you pls help me with some code?
Smith
+1  A: 

I want to thank you guys for your support.

I finally got two options, as i was an expert in php i used sockets. in my c# app, i had two options Httplistener and winsock. Although i experimented with winsock, i finally settled for Httplister.

it worked like a charm

Smith