Anyone have a good tutorial on getting two programs (on the same computer for now) to talk to each other?
Anyone have a good tutorial on getting two programs (on the same computer for now) to talk to each other?
Sockets and a loopback address.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
If it is two apps you have written try
RegisterWindowMessage()
to set up your message.
Then
PostMessage() if you don't want to wait for the other app to process the msg.
or
SendMessage() if you do.
In both cases use HWND_BROADCAST for the hwnd param. This will send the msg to all top level windows. If yours has been coded to respond it will.
The WPARAM and LPARAM can be used to send other data.
GetCurrentProcessId() will help in identifing (multiple instances) which app sent the message. Try sending it as say the WPARAM. The LPARAM can could contain the type of message
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
>>> (on the same computer for now)
The "for now" is the important point here. If they are on the same computer, then there are a number of possibilities, you can exchange messages as novacain has suggested, you can build pipes between the tasks, you can use a mailslot, or another method of allocating shared memory. You can even use a file.
If you intend to network this one day, then most of these will not work and you should use sockets, specifically WinSock.
This is usually the first link I give in these cases.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Thanks for the replys all. I think I'll try my hand at winsocks since I do wish to network the program in the future.