Thread: Getting two programs to communicate

  1. #1
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001

    Getting two programs to communicate

    Anyone have a good tutorial on getting two programs (on the same computer for now) to talk to each other?

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Ontario, Canada
    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

  3. #3
    train spotter
    Join Date
    Aug 2001
    near a computer
    If it is two apps you have written try


    to set up your message.


    PostMessage() if you don't want to wait for the other app to process the msg.


    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

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    >>> (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.

  5. #5
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Recommend upgrade path for C programs
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-22-2007, 07:32 AM
  2. using socket to communicate between programs on one computer
    By axr0284 in forum Networking/Device Communication
    Replies: 2
    Last Post: 03-20-2006, 11:53 AM
  3. POSIX/DOS programs?
    By nickname_changed in forum C++ Programming
    Replies: 1
    Last Post: 02-28-2003, 05:42 AM
  4. Replies: 2
    Last Post: 01-13-2003, 01:28 PM
  5. executing c++ programs on the web
    By gulti01 in forum C++ Programming
    Replies: 4
    Last Post: 08-12-2002, 03:12 AM