dousuiben8395 2013-04-24 08:41
浏览 48
已采纳

使Web服务器携带程序

What I want to do is the following: make a server carry a program which analyses a picture (which is sent to the web server) and returns a result, the program already exists and is written in C# and C++. For interest, this program analyzes a pattern/grid to determine how much pressure is exerted on a metallic object, and takes no more than one second to do its analysis.

I would like to know:

  1. How can I store a program on the web server (alternatively how can I store it so that I can access it from the web server)?
  2. How can I call upon the program through the web server?
  3. I suppose the above calls for some programming with languages such as PHP, but where is this code written/executed?
  • 写回答

2条回答 默认 最新

  • duanhongxian6982 2013-04-24 15:10
    关注

    The simple solution to this problem is the run your program synchronously inside your web request (this means that your web page has to wait for the program to deliver its results). This means that, in your PHP page (or a controller, if you are using an MVC-like architecture) you use system() or similar to run your program on the server. This will probably output results to standard output, or maybe to a file or a database. If your program takes a second to run, this is probably an acceptable delay, as long as you have a low number of users.

    To do this:

    • Store your console program somewhere on the server, "C:\My Programs\My Analyser\Analyser.exe" is fine.
    • You should know the path location of your image file. You can then pass that pathname as a parameter to your console program.
    • You can then retrieve the results of the call, either from stdout or elsewhere, depending on how your console program returns its analysis

    That said, a better way to run this it is to run a job server, so that your program is run asynchronously (this means that your job server accepts a request to run the program, and it will be run when a slot becomes free). This will mean your web page will run faster, and your server won't get overloaded with too many people running your program at the same time. The downside is that the architecture of your system is more complicated, and you'll have to change your UI to cope with unprocessed jobs.

    If you are interested in setting up a job server, consider something like Gearman. You'll have to poll the server to see if a job has been processed, or have your job process write a completion flag to your database, which can be checked trivially by your web script.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用