Discussion:
MailSlot broadcast problem
(too old to reply)
Anoop
2007-01-21 15:43:23 UTC
Permalink
Hi Experts,
Sorry to spam if this topic was already discussed.

I am writing an application using mail slots for a distributed
environment where nodes in the network introduce each other by writing
to a pre-defined mail slot.

Following is a simplistic scenario which is failing for me:

I created a mail slot reader using CreateMailslot(), with name
\\.\mailslot\mymailslot, with sec attributes NULL.
I then created a mail slot writer, through
CreateFile("\\\\*\\mailslot\\mymailslot",
GENERIC_WRITE,
FILE_SHARE_READ,
NULL /*sec*/ , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
NULL /*template*/);

The reader indefinitely waits on a ReadFile() over the handle returned
by CreateMailSlot() above.

When I run this program locally, everything works fine. The writer
writes something and reader is able to receive whatever was written.

But when I run this program on different machines, say the reader on
machine1 and writer on machine2, then they dont work. Both the machines
are on the same domain and I have used the same domain credentials to
login to both the systems. The writer writes something, but the reader
is not able to receive it. It continues its wait for reading!

Again, if I change the wildcards on the writer (CreateFile()) and put
machine1 there, like \\machine1\mailslot\mymailslot, then the writer on
machine2 can write to the reader on machine1. Everything works again!

So why is wild card naming not working for me? I am thus not able to
broadcast any messages! Any clue into this problem will be very helpful
as I am rather blocked by it!

Thanks
Anoop
Sten Westerback (MVP SDK)
2007-01-22 07:47:39 UTC
Permalink
Post by Anoop
Hi Experts,
Sorry to spam if this topic was already discussed.
I am writing an application using mail slots for a distributed
environment where nodes in the network introduce each other by writing
to a pre-defined mail slot.
I created a mail slot reader using CreateMailslot(), with name
\\.\mailslot\mymailslot, with sec attributes NULL.
I then created a mail slot writer, through
CreateFile("\\\\*\\mailslot\\mymailslot",
GENERIC_WRITE,
FILE_SHARE_READ,
NULL /*sec*/ , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
NULL /*template*/);
The reader indefinitely waits on a ReadFile() over the handle returned
by CreateMailSlot() above.
When I run this program locally, everything works fine. The writer
writes something and reader is able to receive whatever was written.
But when I run this program on different machines, say the reader on
machine1 and writer on machine2, then they dont work. Both the machines
are on the same domain and I have used the same domain credentials to
login to both the systems. The writer writes something, but the reader
is not able to receive it. It continues its wait for reading!
Again, if I change the wildcards on the writer (CreateFile()) and put
machine1 there, like \\machine1\mailslot\mymailslot, then the writer on
machine2 can write to the reader on machine1. Everything works again!
So why is wild card naming not working for me? I am thus not able to
broadcast any messages! Any clue into this problem will be very helpful
as I am rather blocked by it!
Broadcasting problems are generally caused by (proper) configuration of
routers in a network. It's very likely that a router on the way just discard
the broadcast packages.
In a client-server environment, and most other setups as well, it doesn't
make sense to bather the network with broadcast as you generally know where
to send the message or at least know which mailslot to ask about it from.
Also keep in mind that over a network it's possible that connectionless
sends won't reach the destination. Named pipes (in message mode) may be a
better choice.

- Sten

Loading...