How do I write a web program to communicate with an exe program on the server? -

Source: Internet
Author: User
(1) an exe program on the server sends data to the web program. When the web program is notified, the result is displayed on the web page of the browser. (2) After pressing the button on the web page of the browser, I want to let an exe on the server know that something has changed. I have prepared the ps. web Applet and an exe program on the server. I don't know how to do it. I used php + mysql to compile a website. However, I feel that this problem does not require a database. That is to say, someone browses the webpage, the data source is to ask that server (1) an exe program on the server side sends data to the web program, when the web program is notified, the result is displayed on the web page of the browser.
(2) After pressing the button on the web page of the browser, some things have changed to be known to an exe on the server.
I have prepared a ps. web Applet and an exe program on the server. I don't know how to do it. I used php + mysql to compile a website. However, I feel that this problem does not require a database. That is to say, someone browses the webpage, the source of the data is to ask the server to obtain an exe program (as for where the exe obtains data, the web program does not know ). How can this problem be solved? I heard that HTML5 has push technology. Can you give me some advice? In addition, an exe program on the server is prepared to be compiled in C ++.
<补充>
The requirement is as follows:
Now there is a desktop application that is controlling a robotic arm, and now wants to control it through a browser (you can use a tablet to control the browser on the tablet), of course, the state of the robotic arm at every moment, and the specific control program is controlled by the desktop application exe. Now I don't know how the server can communicate with this exe program?
Reply content: Although I want to thank the invitation, I 'd like to comment out: This requirement description is messy. I can only summarize the requirements according to my general understanding. @ Edwin: if any, Please point it out.

The requirement is as follows: a program has three components:
  1. Data source: This data source is an executable program that works on the server. It is responsible for actual operations from unknown sources in this requirement.
  2. Server: This is a web server that provides operation interfaces on webpages to control data sources. The server accepts web requests from the client and converts them to operations that can be identified by the data source.
  3. Client: the browser page serves as the client to send web requests to the server. Each web request corresponds to a data-side operation.
There are two interactions: 1-2, 2-3. What I understand now is that neither of the landlords knows how to do it. @ Yang Fan's answer completely covers 2-3, but 1-2 does not.

I have no idea about web, so what I can answer is 1-2. However, before answering the answer, we must continue to clarify several questions:

  1. Data source. What interfaces does this program provide? Generally, there are two types: A: This program is started as A service and sends and receives commands (named pipelines, sockets, etc.) through the communication technology between processes. B: this program is a simple command line. Each time a command line is executed, the specific operation to be executed is determined through the parameters. Of course, there is another variant of each type here, that is, whether to return immediately after the operation is sent (code 0), or wait until the operation ends (Code 1), that is, whether the request is blocked. Therefore, a total of four interfaces are added: A0, A1, B0, and B1.
  2. Client. Does the client support asynchronous request submission? For example, if a button is displayed on the page that indicates "lifting up the manipulator", will the user return immediately after clicking the button or wait until the manipulator is actually lifted?
The two requirements are clarified before the solution can be provided. In general, the following issues need to be considered:
  1. We must map the request types recognized by the data source to HTTP URLs (the fashion point is Restful ). For example, the "lift manipulator" is mapped to: http://server.locahost/raise/arm/0The Data Source Type B may correspond to a command line machineArmOp.exe-ID 0-Action Raise.
  2. The server must be a web app used to analyze the URL string requested by the client and translate it into an operation recognized by the data source. Basically, several common web server-side languages can do this, http://ASP.NETPHP or Python with web framework.
  3. If the data source is Class A, that is, it can communicate remotely, the data source must be started with the server at the same time. Web apps communicate with data sources through interfaces provided by languages. If the data source is A1, a separate step is required, that is, it is best to avoid server blocking in another thread or by using select ()/poll () when the communication is initiated.
  4. If the data source is Class B, that is, it is just a command line, then the Web App needs to use the system-provided interfaces, such as system (), exec (), CreateProcess () create a sub-process and parse its return code or standard output/standard error output information. Similarly, the server Web app may need multiple threads to handle the B1 class to prevent server congestion.
  5. The client can use Ajax based on whether it needs to be blocked. @ Yang Fan's answer is clear.
Another special case is that we cannot eliminate this possibility, that is, we need to write a packaging for the B1 data source. This packaging is also resident in the system as a service. It is responsible for providing a protocol (socket, named pipe, etc.) to communicate with the server. It is a headache to see so many "exe programs". Is lz c born? But in linux, there is no exe...

After reading it for a long time, I probably understood it, that is, the server pushing technology.
There are a lot of such information on the Internet, details can be google.

In the html5 era, web socket can solve this problem, but it is clear that the time is not mature yet.
Before html5, the common method was to use continuous pull for simulation.

There are two common methods
1. use uninterrupted ajax long polling: Create an ajax connection to the server that has timed out for a long time on the page. If the server does not return a message, the ajax will be blocked, once a message is returned or times out, an ajax connection is established to simulate the push effect.
You can use firebug to check the ajax requests, notifications, and homepage updates.

2. using the iframe tag: create a dynamic iframe tag on the page and point src to a server connection. If the server does not return a message, the iframe is always loaded, this can also simulate the push effect.
Gmail was implemented in early years, but it was troublesome to handle the problem that the page status bar always showed "being connected.

As for what you said (2), it's easy. Press the button to float the event and send an ajax request.

As you mentioned, php + mysql is not suitable for handling persistent connections, especially when it is used with apache (because all requests are cleared once ).

We can see that your label is named nodejs. Yes, the non-blocking asynchronous feature of nodejs is more suitable for handling persistent connections than apache + php. I guess LZ is engaged in embedded development and is not familiar with network applications. If yes, try to use existing network development tools. The core code should not exceed 10 lines

1. the browser uses javascript to poll the status and execute commands
Setinterval (function () {jQuery. get ('/status') ;},100 );
JQuery. post ('/destroy_the_earth ');

2. servers (such as PHP pages) interact with desktop programs through system commands
<% Echo system('machine.exe status') %>
<% Echo system('machine.exe destroy_the_earth ') %> this should be done using the server push technology. Google. Should HTML5 web socket be able to communicate over TCP?
Exe program made into server
The web Client nodejs supports c ++ extension and is also easy to be used as a web server. Flash XMLSocket may also work.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.