Darestium
Darestium

Reputation: 653

Using PHP to communicate with a desktop application

Well, I've been playing around with php for the last week or so, and I am wondering how I would use it to get data from a Java application. i.e: the php script sends a request to the server and asks for a response. In my particular case I want to do just that: I would like to have a java application waiting, and the php would "ask a question" to detemine if it is on or off (the server would not respond if it is off, and would if it is on - type of thing).

My question is: How do I communicate with a php script through java. How do I make requests to an application through php?

Any ideas?

Upvotes: 2

Views: 1236

Answers (2)

Chibueze Opata
Chibueze Opata

Reputation: 10044

If your PC is the server, then you can write a Java based server that listens to a socket -> then do something in java program when communication is received. Here's a simple example.

For real life implementation though, I'd suggest you use the PHP/Java Bridge instead. It's much faster and optimized for this sort of operations.

Upvotes: 3

David Stockton
David Stockton

Reputation: 2251

PHP has the ability to make web calls, open and communicate through sockets, SOAP, RPC, etc. It all depends on how your Java program would be listening.

Additionally, PHP can be written as a socket server, so your Java program could talk to it via web calls, socket or any other sort of server technology you choose.

Upvotes: 2

Related Questions