Get two programs to talk to eachother on two separate LANs (send messages?)

Posted on 2009-07-16
Last Modified: 2012-05-07
Hi Experts

I need to send a message from my application on LAN 1 to my application on LAN 2, which simply needs to reply back Yes or No.

This is in deepest darkest Africa so I can only assume there will be some basic internet connectivity using maybe GPRS / 3G technology, or something like that, but probably not ADSL.

I need to know what components I need to use in Delphi, what protocol I would be using, would I be targeting a port, and some source code wouldn't hurt :)

Thank-you in advance.
Question by:rfwoolf
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

AngelGabriel earned 150 total points
ID: 24867723
Well, if connectivity was going to be a problem, I'd implement a store and forward mechanism to communicate. That requires a system that both systems can access all the time, which makes me think internet.

Have a machine online that acts as a go between, or use an exisiting system, such as email, jabber, irc, (irc is a stretch), but you understand my point here, right?

I'm saying don't build a new communications protocol for store and forward, use exitsing mechanisms, and use encryption where neccessary.
LVL 13

Author Comment

ID: 24867770
The problem with store and forward is that it isn't instant. PC 1 stores the message on the irc 'server' and PC 2 needs to know to check for new messages every few minutes which is unideal. Even email would be a similar thing.
Can't we have direct communication here?
In which case if there's a connectivity problem at one site, the communication will just time out I guess
LVL 28

Assisted Solution

by:Bill Bach
Bill Bach earned 150 total points
ID: 24869748
The simplest method of DIRECT communications would be to implement a UDP message passing scheme.  For something like this, though, the two computers would need to be able to see each other on the public network.  However, your original message indicated LAN1 and LAN2, which supposes that the networks will be somewhat protected from each other (likely by a firewall on each LAN).

Let's look at some options:
1) Direct UDP traffic:
- Very Easy to code, but low level
- Short and efficient messages
- No guarantee of delivery
- Direct IP access required (so firewall hole may be needed)
2) Direct TCP traffic
- Fairly Easy to code, but still low level
- Short and efficient messages, but it also supports larger messages
- Guaranteed delivery
- Direct IP access required (so firewall hole may be needed)
3) Relayed UDP traffic:
- Very Easy to code, but low level
- Short and efficient messages
- No guarantee of delivery -- more likely to lose data since now each is sent twice
- You have to ALSO code a relay system on a public server
4) Direct TCP traffic
- Fairly Easy to code, but still low level
- Short and efficient messages, but it also supports larger messages
- Guaranteed delivery
5) Web Services
- Fairly easy to code at the high level, well understood by many developers
- Higher bandwidth requirements
- Web server must be available on the public 'Net, but client does not.
6) Email Relay
- Very easy to code, and well understood
- Messages can be short or large as needed
- Need to write an Email parser, although several ETL tools (like Pervasive's Data Integrator) can handle this automatically
- Neither system needs a public address, but both need Email account access.

There are likely to be several other solutions, which will be allowed or disallowed by your exact network configuration.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 18

Assisted Solution

Johnjces earned 175 total points
ID: 24869986

BillBach hit it on the head as far as protocols. UDP is never guaranteed to be delivered. TCP is... generally.

It does sound like Internet connectivity is present and there has to be (must be, is better) some form of firewall/router on the other end there in deepest darkest Africa. You cannot just send a UDP or TCP packet from one IP to another and expect it to reach the target machine. You will have to port forward through this end device to your target machine.

As an example only....

Lets say you use UDP port 10000. The end user public or Internet IP address is The PC or machine address you need to send/receive to at this Public IP is You have to port forward UDP port 10000 to ip Then simply send your packets from your PC connected anywhere in the world to the INternet to IP

Indy has some GREAT examples/demos on how to code simple to complex IP communications for UDP and TCP. If you use UDP, ensure you get an ack (acknowledgment of some sort back).

You can also use delphi components TServerSocket and TClientSocket. Those use TCP protocols.

I highly recommend you use Indy 9 and first check out the demos. All code is there... it just makes it easy.

If you need anything else, ask...

LVL 18

Expert Comment

ID: 24870015
More on port forwarding....

Some higher end firewalls will allow you to only port forward from a specific Public IP address. Those will also generally allow any public IP address to have its specific ports forwarded. Lower end home type firewall routers seem to only allow port forwarding from ANY public IP address.

Just some more information depending upon security needed.

LVL 37

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 25 total points
ID: 24875241
direct communication
you'll need a VPN (virtual private network)

or both ip addresses will have to be static internet ip adresses
LVL 18

Assisted Solution

Johnjces earned 175 total points
ID: 24875314
or use a dynamic dns service like DynDNS OR dns2go etc.

Most VPNs need some pass through and port forwarding through a firewall/router as well.

LVL 13

Author Comment

ID: 24878593
Thanks John... I hate how with my questions by the time I get decent answers I am already ahead of that answer.
By the time I received your response I had already tried Indy to death and finally (after  much frustration) solved the problem - er, well at least I think I have.
My Delphi has Indy 10. All the good demos are Indy 9, and the only relevant Indy 10 demo I could get used SSL IOHandlers and the SSL DLLs never worked. So I had to change all the SSL IOHandlers to 'Stack' IO Handlers, which is incredible because I don't know the difference between Stack and Stream IO HAndlers.
Anyways, it worked in my demo.

Also the answers I got about port forwarding and VPNs I finally understand now from weeks of investigating VPNs.

Thanks for all the help, I'll let you know if I encounter any problems
LVL 13

Author Comment

ID: 24878825
Geert> Thanks for the comment... You are correct I will need static IP addresses. Further to what I was saying in John, fortunately I already know this :) I proposed DynDNS but then the director moved to interacting with a US server. I used DYNDNS for our server here at the office and I'm not 100% happy with it - I can never be sure when it's working 100% even using its software which is not intuitive enough.
Given the potential problems with DYNDNS I am inclined to also support the US Server option. But we're still working on it

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HP network exams 3 61
Windows update hosed the internet connection to my VMs. 9 64
Applying Computer Settings 12 92
Certifications 8 39
Don’t let your business fall victim to the coming apocalypse – use our Survival Guide for the Fax Apocalypse to identify the risks and signs of zombie fax activities at your business.
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
Internet Business Fax to Email Made Easy - With  eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question