Results 1 to 7 of 7

Thread: [RESOLVED] Best way to facilitate multiple application communication between each other?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Resolved [RESOLVED] Best way to facilitate multiple application communication between each other?

    I have an issue where our IT department has two home-grown apps. One of these apps is still in the development stage. Both of these applications have similar functionality but they do vary which makes them unique. However, the production app needs to provide data to the new app. What we've been pondering is just throwing the data from the production app into a TEXT or CSV file and then have the new app read that file.

    Has anyone ever been in this situation? If so, what was your solution to this or what is the best approach?

    Thanks,
    Blake

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,943

    Re: Best way to facilitate multiple application communication between each other?

    The typical solution is either TCP or UDP. It sounds like both are on a local network, or the same computer, in which case either one would work. UDP is best for fast, tiny, peer-to-peer communications. TCP can be used peer-to-peer, but it most typically used if one program can act as a server (listening for connections) while the other acts as a client (requesting a connection). TCP allows for transferring larger items while UDP works best for smaller items.

    The file transfer you are talking about will also work.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Best way to facilitate multiple application communication between each other?

    Thanks Shaggy...appreciate your input!
    Blake

  4. #4
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,181

    Re: Best way to facilitate multiple application communication between each other?

    Don't know if your apps use a database but if they do then just add a table to one of the databases that both apps can access.

  5. #5
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: Best way to facilitate multiple application communication between each other?

    "Best" is a hard thing to satisfy here. "The one that works and is the easiest to implement" is the best. But you have to know the options!

    At the heart, you have to have a way to serialize and deserialize the data. No matter what technique you choose it can be described as "sending a file". Will it be binary? Will it be text? The determining factor here tends to be if you care to be able to read it easily. Unless it's sensitive data you want to encrypt, textual data is probably the best. CSV? XML? JSON? Use whatever you find easiest to deal with. JSON's my favorite but .NET has the best XML parsers so do what you want.

    How you send the information between them depends on what kind of problems you worry about.

    You could just save a file in a location known and accessible to both programs. If you do this, you need to worry about how A knows B updated the data. Maybe it checks last write time periodically. Maybe the file name has a time component. There's lots of ways to solve this. This is fairly easy to implement and works the best if the rate of saving files is "infrequent". It falls apart if you send data very frequently, then you end up cluttering the disk with tons of files and disk I/O is pretty slow. I guess you also have to worry about "make sure B knows if A is finished before messing with the file".

    TCP or UDP can be used instead. The apps will agree on a port, one will connect to the other, then the file data gets sent. This means "When is data new?" can be answered by "When it arrives." You don't have to worry about cluttering the disk, and you can handle high rates by queuing the sends. Should you use TCP or UDP? Well, people have their druthers. Some say UDP is easier to use. I find it harder to use, but I've done a lot of TCP work. The main difference is TCP can tell you definitively that your data has been sent, is complete, and was received. UDP can only tell you "I sent it", and leaves "Was it complete and was it received?" up to your protocol design. (That sounds harder than it is, once you do it once it's easy.)

    There are other features like Named Pipes, but they're abstractions over TCP, really. It's the same general operation: one program is the "server", and it's the other program's job to be the "client" and connect to it. They handle issues like, "Was it received in order and completely?" for you. (Also, I'm not sure if named pipes can work across two different machines.)

    If I had to choose:

    • I'd try Named Pipes for two programs on the same machine.
    • I'd use TCP or UDP for two programs on different machines. (Most likely I'd create an HTTP REST API between them.)

    The file-based approach, I think, has too many ways it can go wrong to consider.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,943

    Re: Best way to facilitate multiple application communication between each other?

    I got called away in the middle of a sentence. Fortunately, Sitten came in and finished off the thought.

    Passing files around is possible, and is quite likely the easiest to implement unless you have done it before (at which point either TCP or UDP becomes about as easy), but it does have issues. One that Sitten didn't point out is that it is easier to corrupt files than the others. That isn't likely to happen by accident, or computers would be a joke, but if somebody wanted to open a file and mess with it, they could. Messing with TCP or UDP packets is considerably harder.
    My usual boring signature: Nothing

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Best way to facilitate multiple application communication between each other?

    Creating temporary files is what we came up with. As soon as the process is finished, they will be deleted.

    Thanks for all your input!
    Blake

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width