C# Mailslot Control

Remember Mailslots? I do! I do! Gohd, I do..

Back in the day I used Mailslots to create a very simple LAN chat program in Delphi. Now I have re-created that functionality for use in .NET. Here I have a fully working Mailslot control written in C#.

This is one of those technologies that seriously needs to be re-vamped, but while it’s here, let’s use it! What are Mailslots you say? Well… Basically a form of communication between 1 or more computers over UDP. Mailslots are in the form of \\Domain\[MachineName][*]\the\desired\path\to\the\slot.

Mailslots really have nothing to do with the typical concept of "mail". There are 2 kinds of Mailslots, 1st class and 2nd class. If you haven’t guessed, using a * for the machine name will send the message to every computer on the domain specified. This is a 2nd class Mailslot. Had there been a machine name, it would be a 1st class mail slot. What’s the difference? A 2nd class Mailslot uses a broadcast address, a 1st class sends the message directly to the destination. What does this mean to you? Not much, however there is 1 limitation of 2nd class. Let’s say you’re using Mailslots to develop a chat application for the intranet at your company. Seems like a perfect solution doesn’t it? And it is, with one catch. You will run into problems crossing bridges. For example, let’s say you have both a wired and wireless network residing on separate routers which are bridged. Unless specifically configured to allow it, these routers will drop any broadcast packets. What this means is that users on the wired network will be isolated from users on the wireless network. This was the #1 reason I dropped this particular implementation in one of my own projects.

With that said, there are still plenty of uses for Mailslots whether it be for communication between 1 or more applications on a single computer, or for a simple chat program that does specify machine names. Of course those are not the only 2 possible applications but you get the idea. I will not go into the programming details in this post, I have a separate article for that.

You can read the article here as well as download a sample project. If you find it useful, please vote on the project page!

Leave a Reply