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 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。