Exchange Data between two apps across PC on LAN

喜欢而已 提交于 2019-11-27 02:54:10

问题


I have a need of implementing two apps that will exchange data with each other. Both apps will be running on separate PCs which are part of a LAN.

How we can do this in Delphi?

Is there any free component which will make it easy to exchange data between apps across PCs?


回答1:


If I'm writing it myself, I (almost) always use sockets to exchange data between apps.

It's light weight, it works well on the same machine, across the local network or the Internet with no changes and it lets you communicate between apps with different permissions, like services (Windows messages cause problems here).

It might not be a requirements for you, but I'm also a fan of platform independent transports, like TCP/IP.

There are lots of free choices for Delphi. Here are a few that I know of. If you like blocking libraries, look at Indy or Synapse. If you prefer non-blocking, check out ICS.




回答2:


Before you choose a technique, you should characterize the communication according to its throughput, granularity, latency, and criticality.

Throughput -- how much data per unit time will you need to move? The range of possible values is so wide that the lowest-rate and highest-rate applications have almost nothing in common.

Granularity -- how big are the messages? How much data does the receiving application need before it can use the message?

Latency -- when one aplication sends a message, how soon must the other application see it? How quickly do you want the receiving application to react to the sending application?

Criticality -- how long can a received message be left unattended before it is overrun by a later message? (This is usually not important unless the throughput is high and the message storage is limited.)

Once you have these questions answered, you can begin to ask about the best technology for your particular situation.

-Al.




回答3:


I used to use Mailslots if I needed to communicate with more than one PC at a time ("broadcast") over a network, although there is the caveat that mailslots are not guaranteed.

For 1-to-1, Named Pipes are a Windows way of doing this sort thing, you basically open a communication channel between 2 PCs and then write messages into the pipe. Not straight forward to start with but very reliable and the recommended way for things like Windows Services.

MS offer Named Pipes as an alternative way of communicating with an SQL Server (other than TCP/IP).

But as Bruce said, TCP/IP is standard and platform independent, and very reliable.




回答4:


DCOM used to be a good method of interprocess communication. This was also one of Delphis strong points. Today I would strongly advice against using it.

Depending on the nature of your project I'd choose either

  • using a SQL server
  • socket communication



回答5:


Look at solutions that use "Remote Procedure Call" type interfaces. I use RemObjects SDK for this sort of thing, but there are open source versions of RealThinClient which would do just as well.

Both of these allow you to create a connection that for most of your code is "transparent", and you just call an interface which sends the data over the wire and gets results back. You can then program how you usually do, and forget the details of sockets etc.




回答6:


This is one of those cases where there really isn't a "best" answer as just about any of the technologies already discussed can be used to accurately communicate between two applications. The choice of which method to use will really come down to the critical nature of your communication, as well as how much data must be transfered from one workstation to another.

If your communication is not time sensitive or critical, then a simple poll of a database or file at regular intervals might be sufficient. If your communication is critical and time sensitive then placing a TCPIP server in each client might be worth pursuing. If just time sensitive then mailslots makes a good choice, if critical but not time sensitive then named pipes.




回答7:


I've used the Indy library's Multicast components (IdIPMCastClient/Server) for this type of thing many times. The apps just send XML to each other. Quick and easy with minimal connection requirements.




回答8:


Probably the easiest way is to read and write a file (or possibly one file per direction). It also has the advantage that it is easy to simulate and trace. It's not the fastest option, though (and it definitely sounds lame ;-) ).




回答9:


A possibility could be to "share" objects across the network.

It is possible with a Client-Server ORM like our little mORMot.

This Open Source libraires are working from Delphi 6 up to XE2, and use JSON for transmission. There is some security features included (involving a RESTful authentication mechanism), and can use any database - or no database at all.

See in particular the first four samples provided, and the associated documentation.




回答10:


For Delphi application integration, a message oriented middleware might be an option. Message brokers offer guaranteed delivery, load balancing, different communication models and they work cross-platform and cross-language. Open source message message brokers include:

  • Apache ActiveMQ and ActiveMQ Apollo
  • Open Message Queue (OpenMQ)
  • HornetQ
  • RabbitMQ

(Disclaimer - I am the author of Delphi / Free Pascal client libraries for these servers)



来源:https://stackoverflow.com/questions/1254698/exchange-data-between-two-apps-across-pc-on-lan

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!