Mailslots enable applications to create and store messages during execution. These mailslots are usually deleted as the last step of the programs execution.
The functions in the Mailslot category provide one-way interprocess communications (IPC).
|
Function |
Description |
|
Deletes a mailslot, discarding all messages, whether or not they have been read. |
|
|
Provides information about a specified mailslot. |
|
|
Creates a mailslot and returns its handle. |
|
|
Reads the most current message (based on priority) in a mailslot without removing it. |
|
|
Reads, then removes a mailslots most current message (based on priority). |
|
|
Writes a message to a specified mailslot. |
Through Advanced Server mailslots, data can be sent to either local or remote applications on the network. The Mailslot functions create and delete mailslots, retrieve information about a mailslot or a message in it, and write messages to mailslots.
An application creates a mailslot on a local computer by calling the DosMakeMailslot function 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 function returns a handle to the mailslot. This handle can then be used as follows:
with DosPeekMailslot to read a message in a mailslot
with DosReadMailslot to read and remove a message
with DosMailslotInfo to return information on a mailslot
with DosDeleteMailslot to delete a mailslot
Any application can write messages to any mailslot on any computer on the network by calling the DosWriteMailslot function. DosWriteMailslot accepts mailslot names both in a local and remote format, as follows:
|
Type |
Format |
|
Local mailslot |
\mailslot\name |
|
Remote mailslot |
\\computername\mailslot\name |
|
Mailslot to domain |
\\domainname\mailslot\name |
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 names must be unique).
An application can write the same message to all computers in the primary domain on the network that have a mailslot of a particular name by specifying an asterisk ( * ) for computer name when calling DosWriteMailslot. For example, \\*\mailslot\name sends the same message to the named mailslot on every computer on the network that has the locally created mailslot.
Two classes of messages, first-class and second-class, can be sent to mailslots.
First-class messages, limited to mailslots on local computers and remote servers, are guaranteed the message will be delivered or the sender will be notified. 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. This is controlled by the timeout parameter in the DosWriteMailslot function.
Second-class messages are simply sent; no return code informs the sender of an unsuccessful delivery. This delivery system tends to make second-class messages faster than the first-class messages.
UNIX system applications can receive first-class and second-class mailslot messages. UNIX system applications can send second-class mailslot messages to local or remote servers and first-class messages to the local server.
Messages are stored in the mailslot according to when they were sent and the priority assigned them. Messages written from one UNIX system server to another UNIX system server must be sent by second-class mail.
Mailslot messages can be read or peeked at only by the process that created the mailslot.
The DosReadMailslot function reads and then removes the most current message. It also allows you to look at the next message in the mailslot without removing it.