Jump to content
  • Advertisement
Sign in to follow this  
Blednik

Interprocess communication

This topic is 3619 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Heya. I am looking for a way to have two processes communicate to each other in Windows XP, but I am uncertain which path to use as there seem to be many methods for IPC. I've been leaning toward named pipes, but the documentation online is rather scarce and incomplete. There are only two processes in the plan (both written in C++), one of them being windowless. The GUI process should be able to control the windowless one using IPC and they'll need to transfer over certain commands and small bits of data to each other. Any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
*bump*

This is as far as I managed to get with named pipes.
http://www.codeguru.com/forum/showthread.php?t=468573

Share this post


Link to post
Share on other sites
Well, there are many other ways to do IPC. I just looked at a friend's code which used named pipes and it's just horrible to communicate that way. You may want to look into several other ways to implement IPC:

http://zeroc.com/ice.html
http://www.codeproject.com/KB/IP/cnamedpipe.aspx (This one is just a wrapper for the Win32 api functions, it is old, but could be worth a look, if only to see how it's done)

About the problems you mentioned on codeguru. Maybe we can help if you post the relevant code in this forums (and/or their's as well), so we can try to determine what's going wrong.

Share this post


Link to post
Share on other sites
Can you give us a high level overview of what the two processes are doing?

Does the GUI process create or spawn the windowless one, or vice versa? Or can the windowless one run in complete isolation?

Towards the future, would the ability to connect the GUI to a remote computer running the other process be desired?

The "best choice" depends on quite a number of factors, of which you have only really described the data flow.

Share this post


Link to post
Share on other sites
I've taken an interest in named pipes because of a recommendation from a more experiended coder. Both, the server and client should only run on a local computer i.e. there is no need for a remote connection.
The GUI application (the server) spawns the windowless client on request. The client then attempts to connect to the server and begins the data exchange. Should the connection fail (e.g. server is absent), the client automatically terminates. The client cannot run on its own and it relies on the server for commands. This is merely the concept of the final application and I am currently in the state to get the IPC going.
Please note that the following code is only a prototype for the IPC part. Just split it into files and you should be able to compile it. You have to execute the server.exe and then the client.exe manually.

Server: http://pastebin.com/m683c29b1
Client: http://pastebin.com/m5e95d9eb

I've managed to get the data to flow in one direction at a time by commenting out certain write/read parts of the code, but both applications freeze when trying to read and write to the pipe on both sides (server and client-side) at the same time.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!