Solved

Mailbox Events

Posted on 2000-05-02
4
309 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tab names are off by one 5 53
sumNumber challenge 16 109
changeXy challenge 13 67
Detect file exist or not 3 128
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

919 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now