🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: MailSlots and messages longer than 424 bytes

#840
From: AlexB
Date: Tue, 04 Dec 2007 05:01
69 lines
2903 bytes
Bob Gonder wrote:

> Show your actual code ?

It's part of JVCL's JvgMailSlot (slightly modified):

procedure TJvgMailSlotServer.Open;
begin
 <...>
// no matter what timeout I specify here (0 or MAILSLOT_WAIT_FOREVER)
  FHandle:=CreateMailSlot(PChar('\\.\mailslot\'+MailSlotName),0,0,nil);
  if FHandle=INVALID_HANDLE_VALUE then <Err...>
  FTimer.Enabled:=True;
end;

procedure TJvgMailSlotServer.OnTimer(Sender: TObject);
var
  MsgSize: DWORD;
  MsgNumber: DWORD;
  Read: DWORD;
  Buffer: Pointer;
begin
  // Determining if there's message
  if not GetMailSlotInfo(FHandle, nil, MsgSize, @MsgNumber, nil)
  then <Err...> 
  else
    if MsgSize<>MAILSLOT_NO_MESSAGE
    then begin
      FData.Size:=MsgSize; // Allocate memory
      Buffer:=FData.Memory;
      // Reading message
      if ReadFile(FHandle, Buffer^, MsgSize, Read, nil)
      then <OK...>
      else <Err...>
    end;        
end;

function TJvgMailSlotClient.Send
 (const MessageData; MessageLength: integer): Boolean;
var
  FHandle: THandle;
  Written: DWORD;
begin
  if FServerName='' then FServerName:='.\'; // the same computer
  FHandle:=CreateFile(PChar('\\'+FServerName+'\mailslot\'+
FMailSlotName), GENERIC_WRITE, FILE_SHARE_READ, nil, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);
  Result:=FHandle<>INVALID_HANDLE_VALUE;
  if Result then
  begin
    Result:=WriteFile(FHandle, MessageData, MessageLength, Written,
nil);
    CloseHandle(FHandle);
  end;
end;

Send works normally (always returns true).
Local messaging ('.\') with length up to 64K work without problems.
Network messaging (i.e. where name of computer was specified):
 - up to 425 bytes in any case
 - up to 1365 bytes after installation of NetBEUI.

Server never see network messages longer then 1365 bytes
(i.e. MsgSize=MAILSLOT_NO_MESSAGE).

MSDN says that for long messages (up to 64K) mailslots require "SMB
session". I have no idea how to check the presence of SMB session.
-- 
Alex
Technical Details
Message-ID: <4754ed37@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4750140f@newsgroups.borland.com> <4752978b@newsgroups.borland.com> <475405ba@newsgroups.borland.com> <q2k9l3dlb97lddjgtvlksbj0sejqkij9sk@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,5f39732d3fb3000f
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "AlexB" <b.a.v@inbox.ru>
Subject: Re: MailSlots and messages longer than 424 bytes
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4750140f@newsgroups.borland.com> <4752978b@newsgroups.borland.com> <475405ba@newsgroups.borland.com> <q2k9l3dlb97lddjgtvlksbj0sejqkij9sk@4ax.com>
User-Agent: XanaNews/1.18.1.6
NNTP-Posting-Host: 212.192.185.54
Message-ID: <4754ed37@newsgroups.borland.com>
Date: 3 Dec 2007 22:01:27 -0700
X-Trace: newsgroups.borland.com 1196748087 212.192.185.54 (3 Dec 2007 22:01:27 -0700)
Lines: 69
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail