Click to See Complete Forum and Search --> : Mailslots between computers


oscar
May 23rd, 1999, 11:24 AM
I use mailslots in Windows95 and WindowsNT.

When I send messages between processes on the same computer
it is worked correctly.

When I send messages between processes on the different computers
it is not worked correctly. I send message from one computer and
receive on the other computer several same messages
(see source code). I lost them, but I can lost a new message too.

This part of source based on Microsoft sample from the Help of Developer
Studio.
It is like as a mistake of internal Windows processing of mailslots
mechanism.

Does anybody knows what is the reason?
...
char MailMessage[10000];
...

DWORD Run()
{
BOOL fresult;
DWORD cbmessage;
DWORD cmessage;
DWORD IdleTime = 1000;
DWORD MailMessageSize;

for (;;)
{

fresult = GetMailslotInfo(hMailSlot,(LPDWORD)NULL,
&cbmessage, &cmessage,(LPDWORD)NULL );
if (!fresult) return FALSE;
if (cbmessage == MAILSLOT_NO_MESSAGE)
{
Sleep(IdleTime);
continue; // No waiting messages
}

// Mailslot message is received
while (cmessage)
{
// Here I get the current message
fresult = ReadFile (hMailSlot,
MailMessage,
cbmessage,
&MailMessageSize,
(LPOVERLAPPED)NULL);

Processing();
// If I send messages between processes on the same computer
// it is right
// If I send messages between processes on the different computer:
// Here I get messages same the current message
// and lost them
while (cmessage)
{
fresult = GetMailslotInfo(hMailSlot,(LPDWORD)NULL,
&cbmessage, &cmessage,(LPDWORD)NULL );
if (!fresult)
return FALSE;
fresult = ReadFile (hMailSlot,
MailMessage,
cbmessage,
&MailMessageSize,
(LPOVERLAPPED)NULL);
}
}
}
return TRUE;
}