简体   繁体   中英

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. ie: 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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM