🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10556

Mailslot stutters

#10556
From: Gary Setter
Date: Mon, 05 Apr 2004 00:56
51 lines
2645 bytes
Hi,

I'm trying to understand mailslots by playing with the MSDN sample.
What I'm seeing is for ever WriteFile that the client does, GetMailslotInfo
indicates that two messages are ready to read.


This is how I create the mailslot  in the server.
    LPSTR lpszSlotName = "\\\\.\\mailslot\\sample_mailslot";


    HANDLE hSlot1 = CreateMailslot(lpszSlotName,
        0,                             // no maximum message size
        MAILSLOT_WAIT_FOREVER,         // no time-out for operations
        (LPSECURITY_ATTRIBUTES) NULL); // no security attributes

This is how I write to the mailslot in the client:

 hFile = CreateFile("\\\\*\\mailslot\\sample_mailslot",
   GENERIC_WRITE,
   FILE_SHARE_READ,  // required to write to a mailslot
   (LPSECURITY_ATTRIBUTES) NULL,
   OPEN_EXISTING,
   FILE_ATTRIBUTE_NORMAL,
   (HANDLE) NULL);

 fResult = WriteFile(hFile,
   lpszMessage,
   (DWORD) lstrlen(lpszMessage) + 1,  // include terminating null
   &cbWritten,
   (LPOVERLAPPED) NULL);

 fResult = CloseHandle(hFile);



This is how I check the number of messages available in the server:

  fResult = GetMailslotInfo(hSlot1, // mailslot handle
   (LPDWORD) NULL,               // no maximum message size
   &cbMessage,                   // size of next message
   &cMessage,                    // number of messages
   (LPDWORD) NULL);              // no read time-out

Again, the message count is twice the number of messages actually written.

Can anyone tell me why?
Gary

I'm uploading the full sample to attachments with the same subject (Mailslot
stutters)
Technical Details
Message-ID: <4070af2f@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!transit.news.xs4all.nl!newsfeed.wirehub.nl!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,46bec353392a3907,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-04-04 18:09:25 PST
From: "Gary Setter" <setterg@worldnet.att.net>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Mailslot stutters
Date: Sun, 4 Apr 2004 19:56:36 -0500
Lines: 52
MIME-Version: 1.0
Content-Type: text/plain;
 charset="Windows-1252"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 12.74.20.91
Message-ID: <4070af2f@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1081126703 12.74.20.91 (4 Apr 2004 17:58:23 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!transit.news.xs4all.nl!newsfeed.wirehub.nl!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail