title: Simple Mailslot program not working?
body: <p>Using the client and server examples found here: <a href="http://www.winsocketdotnetworkprogramming.com/winsock2programming/winsock2advancedmailslot14.html" rel="nofollow noreferrer">http://www.winsocketdotnetworkprogramming.com/winsock2programming/winsock2advancedmailslot14.html</a> Compiling them with VS2008, running the server and then "client Myslot" I keep getting "WriteFail failed with error 53." Anyone have any ideas? Links to other Mailslot examples are also welcome, thanks.</p>
  
  <p>Server:</p>
  
  <pre><code>    // Server sample
  #include &lt;windows.h&gt;
  #include &lt;stdio.h&gt;
  
  void main(void)
  {
  
      HANDLE Mailslot;
      char buffer[256];
      DWORD NumberOfBytesRead;
  
      // Create the mailslot
  
      if ((Mailslot = CreateMailslot("\\\\.\\Mailslot\\Myslot", 0, MAILSLOT_WAIT_FOREVER, NULL)) == INVALID_HANDLE_VALUE)
      {
          printf("Failed to create a mailslot %d\n", GetLastError());
          return;
      } 
  
      // Read data from the mailslot forever!
  
      while(ReadFile(Mailslot, buffer, 256, &amp;NumberOfBytesRead, NULL) != 0)
      {
          printf("%.*s\n", NumberOfBytesRead, buffer);
      }
  }
  </code></pre>
  
  <p>Client:</p>
  
  <pre><code>// Client sample
  
  #include &lt;windows.h&gt;
  #include &lt;stdio.h&gt;
  
  void main(int argc, char *argv[])
  {
      HANDLE Mailslot;
      DWORD BytesWritten;
      CHAR ServerName[256];
  
      // Accept a command line argument for the server to send a message to
  
      if (argc &lt; 2)
      {
          printf("Usage: client &lt;server name&gt;\n");
          return;
      }
  
      sprintf(ServerName, "\\\\%s\\Mailslot\\Myslot", argv[1]);
  
      if ((Mailslot = CreateFile(ServerName, GENERIC_WRITE,
  
          FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE)
      {
          printf("CreateFile failed with error %d\n", GetLastError());
          return;
      }
  
      if (WriteFile(Mailslot, "This is a test", 14, &amp;BytesWritten, NULL) == 0)
      {
          printf("WriteFile failed with error %d\n", GetLastError());
          return;
      }
  
      printf("Wrote %d bytes\n", BytesWritten);
      CloseHandle(Mailslot);
  }
  </code></pre>