A mailslot is a (temporary) RAM-based file to which numerous records of data can be written and read by several computers on the same network (ie, domain).

A REXX script running upon one particular computer creates a mailslot in its computer's memory (while the script is running). That computer and REXX script then becomes the "server". The server script can read any record that any other REXX script running upon any other networked computer writes (ie, sends) to that particular mailslot. These other scripts/computers are then "clients". The operating system takes care of sending the record's contents (ie, data) over the network. The client script merely needs to call one operating system function to write a record to the mailslot. And the server script merely needs to call one operating system function to read a record.

Note: Only the server script can read the records in the mailslot it creates. The clients are restricted to only writing records.

Many client scripts can write records to a particular mailslot simultaneously. The messages are "queued" in the order that they arrive at the mailslot, and stored there in the server's RAM until such time as the server script reads them. But, the server script can also simultaneously be reading records from the mailslot while the clients are writing to it. (The server script calls an operating system function to read one record at a time. The records are retrieved the same order that they are queued. So, a mailslot is an awful lot like a REXX DATA QUEUE, except it transparently works over a network and is RAM-based).

As soon all of these scripts end (ie, the server script, as well as all client scripts that write to that particular mailslot), then the mailslot file is automatically deleted from the memory of the server computer (and any unread data inside it is discarded).

The data inside a record can be in any format. It can be text (which would be typical for a REXX script since data in REXX is inherently all text-based). Or it could be binary data. The author of the server script will ultimately decide what sort of data format he desires for a record (and of course, the client scripts must be aware of the format too in order to write correct records). Therefore a record can really be any amount or type of data. (But the size of a record should be less than 64000 bytes, or the operating system may choke upon it). A server script could even allow numerous types of records, and have the first piece of data in a record tell what the remaining data in a record is all about. It's really up to the creator of a mailslot to determine what he wants to do with it.

Boring technical note

Records smaller than 425 bytes are sent using datagrams. Records larger than 426 bytes are sent using a connection-oriented transfer over an SMB session. Connection-oriented transfers are limited to one-to-one communication from one client to one server. Note that Windows does not support records that are 425 or 426 bytes.