MFC程序启动了一个控制台程序,现在需要在两个进程间进行交互,而最大的问题在于....
工作进程是一个WIN32的控制台程序,是一个服务器,一直处于运行状态;现在用MFC实现了界面,并启动了工作进程,需求是能够在父子进程之间进行通信,以便控制进行交互和控制。求给些思路啊,或者代码。
[解决办法]
内存映射文件
[解决办法]
Interprocess Communications
For an application to take complete advantage of the features in the Microsoft? BackOffice? environment, you must design it to communicate with other applications as well as with components within BackOffice. Typically, cooperating and communicating applications can be categorized as clients or servers. A client is an application or a process that requests a service from some other process. A server is an application or a process that responds to a client request. Many applications act as both a client and a server, depending on the situation. The process of communication between two or more applications, regardless of their client/server status, is called interprocess communications (IPC).
Before you decide which IPC mechanisms to use in the development of your application, you should determine whether:
The application should be able to communicate with other applications running on other computers, or whether it is sufficient for the application to communicate only with other applications on the local computer. Some IPC mechanisms work either on the local computer or over a network; others work only on the local computer.
The application should be interoperable, able to communicate with other applications on other computers that may be running under different operating systems (for example, Microsoft? MS-DOS?, Microsoft? Windows? version 3.x, UNIX).
The user of your application should have to intervene to choose the other application with which the application communicates, or whether your application can implicitly find its cooperating partners.
Performance is critical to the application. All IPC mechanisms include some amount of communications overhead.
Many IPC mechanisms, such as dynamic-link libraries and shared memory, are implemented only on the local system. Other IPC mechanisms, such as distributed COM (DCOM) and remote procedure calls (RPCs), find their primary functionality across networks and between different computer systems. Each IPC mechanism has unique features that singularly describe it, and which you should consider during the development of your application.
Considerations for choosing the appropriate IPC mechanisms are shown in the following diagram.
[解决办法]
共享临时文本文件这种进程之间的通讯方法相比其它方法的优点有很多,下面仅列出我现在能想到的:
·进程之间松耦合
·进程可在同一台机器上,也可跨机,跨操作系统,跨硬件平台,甚至跨国。
·方便调试和监视,只需让第三方或人工查看该临时文本文件即可。
·方便在线开关服务,只需删除或创建该临时文本文件即可。
·方便实现分布式和负载均衡。
·方便队列化提供服务,而且几乎不可能发生队列满的情况(除非硬盘空间满)
·……
[解决办法]