This category includes the following APIs:
Mailslot - DosDeleteMailslot
Mailslot - DosMailslotInfo
Mailslot - DosMakeMailslot
Mailslot - DosPeekMailslot
Mailslot - DosReadMailslot
Mailslot - DosWriteMailslot
Mailslot APIs provide one-way interprocess communication (IPC). They are used with the MAILSLOT.H and NETCONS.H header files.
Through LAN Server mailslots, data can be sent to either local or remote applications on the network. Calls to these APIs must, however, be issued locally. The Mailslot functions create and delete mailslots, retrieve information about a mailslot or a message in it, and write messages to mailslots.
Mailslots can be read or deleted only by the process that created them. Mailslots created by a process are deleted when that process ends.
An application creates a mailslot on a local computer by calling the DosMakeMailslot API and assigning the mailslot a name in the format:
\mailslot\name
where name is a unique set of characters distinguishing the mailslot from other mailslots on the computer.
The DosMakeMailslot API returns a handle to the mailslot. This handle then can be used in the following ways:
Any application can write messages to any mailslot on any computer on the
network by calling the DosWriteMailslot API. DosWriteMailslot accepts mailslot
names both in a local and remote format, as follows: ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿³FORMAT
³TYPE ³
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
³ \"mailslot"\name ³ Local mailslot ³
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
³ \\computername\"mailslot"\ name ³ Remote mailslot ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
To write data to a mailslot on a remote computer, the name of the mailslot must also include a computer name. This requirement enables multiple remote computers to use the same mailslot name locally, but to have different names on the network. (The computer name must be unique.)
Two classes of messages, first-class and second-class, can be sent to mailslots.
First-class messages can be sent to servers and peers, but not to requesters. Delivery of first-class messages is guaranteed: a message is either delivered or the sender is notified if the message is not delivered. If a mailslot is full when a first-class message arrives, DosWriteMailslot waits until DosReadMailslot reads and removes a message from the mailslot or until the delivery timeout expires (controlled by the timeout parameter in the DosWriteMailslot API).
Second-class messages simply are sent; no return code informs the sender of an unsuccessful delivery. This simpler delivery system tends to make second-class messages faster than first-class messages. Second-class messages sent to a destination on a local workstation are received on the workstation as first-class messages, with guaranteed delivery.
An application can write the same message to all computers on the network that have a mailslot of a particular name. Only second-class delivery is provided. By specifying an asterisk (*) for the computer name when calling DosWriteMailslot,
\\*\mailslot\namesends the same message to the named mailslot on every computer in the sender's primary domain that has the locally created mailslot. There is one limitation: requesters can receive only second-class messages of up to 400 bytes in length. Servers can receive first-class or second-class messages of any size.
Messages are stored in the mailslot according to when they were received and the priority assigned them. Each message is assigned a priority from 0 (low) through 9 (high) by way of the priority parameter of the DosWriteMailslot API. Generally, priorities dictate the order in which messages are stored in a mailslot. High-priority messages are placed ahead of previously stored messages with the same or lower priority. However, since the OS /2 program is a multitasking operating system, this scheme cannot be guaranteed.
Mailslot messages can be read only by the process that created the mailslot.
The DosReadMailslot API reads and then removes the most current (next available) message. Since new messages might be placed in front of other messages because of priority, a process cannot guarantee that a message read by DosReadMailslot is the same message seen earlier by DosPeekMailslot.
For related information about interprocess communications (IPC) in this book, see Named Pipe Category.