Solved

Mailbox Events

Posted on 2000-05-02
4
313 Views
Last Modified: 2013-11-20
How can I receive "notifications"/events when information is written into a mailslot?

I would thus like to do something like
WaitForSingleObject(SlotWriteEvent, INFINITE) or something equivalent, instead of polling the mailslot

0
Comment
Question by:OD
  • 3
4 Comments
 
LVL 1

Expert Comment

by:poohbear_68
ID: 2829118
When you create the mailslot, specify MAILSLOT_WAIT_FOREVER for the lReadTimeout parameter.
0
 
LVL 1

Accepted Solution

by:
poohbear_68 earned 50 total points
ID: 2829127
Or if you want to switch between the modes you can use the following code:

SetMailslotInfo(hMailslot, 0);  // Return immediately
SetMailslotInfo(hMailslot, MAILSLOT_WAIT_FOREVER);  // Return when message arrives
0
 

Author Comment

by:OD
ID: 2832023
PoohBear,

Your answer does make sense to me and I think I will probably accept the answer (I can not test if for another week or so). Just a general question before I accept, can I "peek" into the mailslot, thus retrieve a message without removing it from the slot? (Especially for variable length messages, so that I can check a header with the message length)
0
 
LVL 1

Expert Comment

by:poohbear_68
ID: 2834086
You cannot read from a mailslot without removing the data.  But you can retrieve the length of the next message using GetMailslotInfo.

// You must initilize hMailslot to the value returned by CreateMailslot
DWORD dwSizeOfNextMessage;
GetMailslotInfo(hMailslot, NULL, dwSizeOfNextMessage, NULL, NULL);
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Include multiple hostnames in this command? 3 55
Process filename extension 3 185
Complete beginner needs help making a cron job 9 116
dog bark java program 15 95
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question