Mar 8th, 2013, 04:34 AM
VB6 - MailCall: LAN App to App Alerts
Sometimes when a data client application can be in use by multiple people it may be useful to know when certain updates have been done so you can requery. This can be true whether you use a database or a set of random files... or some other shared resource. In theory you might even use it to monitor progress reports from a "batch" program running on another PC.
Perhaps you have a customer list table in a database and you use it to populate a Customer ListBox. When somebody adds a new customer you might want to reload your ListBox.
Now, you could beat on the database almost continuously using a Timer to reload every few seconds. This has performance implications though and they can be very serious when you use a shared file-based DBMS such as Jet.
You can add a MailCall instance to a Form as an alternative.
MailCall has a Listen() method that you pass a Name to that is unique to your application. This causes MailCall to create the server end of a Mailslot and set up a broadcast name that it will use when you call its Send() method.
Send() accepts a String of up to to 100 Unicode characters and broadcasts it to all other computers on the LAN.
MailCall has its own Timer control that it uses to poll for inbound broadcasts every 1 to 65 seconds (set via the PollInterval property).
When this Timer's event handler reads an inbound message it will optionally skip any originating from itself depending on the value of the ReportLocal property. It also skips duplicate message payloads it finds during that poll since it is possible for Mailslot broadcasts to be delivered more than once depending n your network configuration).
If these criteria are met it raises its Receive() event, passing the data payload.
By passing different Name values to Listen() calls you can reuse MailCall in separate applications without collisions.
Your 0 to 100 characters of Data can be whatever makes sense for your application. It might be empty, just a "ping" to everyone. Or it might be a database table name. Or it might be a signal from an "admin" program saying to close the database because maintenance is going to be performed.
You should be able to format the DATA as any Unicode characters, even NULs though that's usually not valuable. And you can parse incoming Data and act upon it in any way you see fit.
You can make up a protocol with a Msg ID code and comma-separated parameters. As long as it fits within 100 characters.
If desperate, you can also jam up to 200 ANSI characters into the String.
Most of these are spelled out in the comments within MailCall. it should work on any machine that can run VB6 programs.
In case it isn't clear: Mailslots do not work over the Internet. Again, see the comments for more detail.
Your PCs' firewalls must permit MS Networking traffic ("File and Printer Sharing"), and all of the machines must be in the same Workgroup or Domain.
Win9x clients have limitations on the Mailslot names they can use. There can only be one Mailslot server for a given Mailslot name in one PC.
So you can't really test the Demo thoroughly by running two copies on your computer.
But since there are no Demo dependencies aside from (a.) Windows and (b.) the VB6 runtime you could run A second Windows OS in a VM with networking support (and in the same Domain or Workgroup) and copy the compiled EXE there to test "pinging" back and forth between a copy on your PC and running in the VM.
And you can run the Demo standalone, talking to itself. Normally though an application instance doesn't want to see its own broadcasts (see the comments).
Tags for this Thread
Click Here to Expand Forum to Full Width
Survey posted by VBForums.