search

Home  >  Q&A  >  body text

c++ - 后台程序提供API供其它程序使用

最近遇到了一个问题,就是我想写一个程序,我可以启动它,在后台运行,该程序可以提供函数接口做一些操作。然后其它程序可以通过包含后台程序的头文件,使用后台程序的函数。

想了好久不知道,该怎么做。求各位帮助啊。

阿神阿神2886 days ago721

reply all(5)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 11:47:40

    It is recommended to refer to Inter-Process Communication (RPC)
    However, it may not be possible to directly include the header file of the background program and use the functions of the background program

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:47:40

    The simplest way is to redirect the standard input and standard output and control the background program through them.

    http://stackoverflow.com/questions/2680174/redirect-stdin-in-c-program-to-another-process

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:47:40

    The program started in the background is a service (a memory-resident process, A), and the subsequent program (called program B) and A can communicate in various ways;
    After being able to communicate, all functions in A can be called at will (of course, through the protocol negotiated by both parties);
    If you need to directly expose a function to the outside world, in fact, you need to publish this function as a service for other users to use;

    Publish functions into services. Some middleware services do this, such as Tuxedo;

    There are many ways to communicate between processes,
    For example, pipes; shared memory, queues, etc.; refer to "UNIX Network Programming Volume 2" inter-process communication: http://www.me115.com/book/129.html

    Perhaps your requirement is just a dynamic link library to package A's code into a dynamic library,
    Expose the header file interface for B to use? In this way, there is only one process;

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 11:47:40

    Extract the parts shared by the current background program and other programs into a dynamic library

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 11:47:40

    webService,soap

    reply
    0
  • Cancelreply