One caveat is that sometimes your server script will receive two or more duplicate copies of a single record written by the client. This is because Windows automatically ships out a copy of the record using every installed protocol on the client.

One way around this is to have the client script embed within the record the CPU's current time since the script stated (which can be gotten with TIME('U')) and then the User's Name (gotten with USERID()).

Then when your server script receives a record, it can compare the USERID and time with previously received records, and discard the record if these match a previous record.

Here's an example of the client script prepending the time and username before the record data (and separating them with a comma):


IF CHAROUT(mailslotname, TIME('U')  USERID() || "," || "This is some text") \== 0 THEN
   SAY "ERROR writing mailslot:"  STREAM(mailslotname, 'D')
And here is how the server script can detect a duplicate message:
/* At the start of the script, these must be initialized to defaults */
lastTime = ""
lastUser = ""

/* Here the script would create a mailslot and read records
 * from it. Assume the next record has been read into
 * the variable "buffer".
 */

/* Chop apart the TIME, USERNAME, and record data */
PARSE VAR buffer thisTime thisUser ',' data

IF thisTime = lastTime & thisUser = lastUser THEN SAY "Duplicate message"
ELSE DO
   /* This is not a duplicate message, so save this info */
   lastTime = thisTime
   lastUser = thisUser

   /* Because of the PARSE VAR, we have an extra leading space
    * on our data. You can strip if off with STRIP()
    */

END