title: Creating Named Pipe Error
body: <p>I am creating a named pipe and using a function to do so. Here is the code:</p>
  
  <pre><code>HANDLE              tProviderPipe(INVALID_HANDLE_VALUE);
  SECURITY_ATTRIBUTES tSecurityAttributes;
  
  tSecurityAttributes.nLength = sizeof(tSecurityAttributes);
  tSecurityAttributes.bInheritHandle = FALSE;
  tSecurityAttributes.lpSecurityDescriptor = NULL;
  while (1)
  {
      tProviderPipe = ::CreateNamedPipe(L"\\\\.\\pipe\\MyPipe",
                                        PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
                                        PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
                                        1,
                                        128,
                                        128,
                                        5000,
                                        &amp;tSecurityAttributes);
  
      if (INVALID_HANDLE_VALUE != tProviderPipe)
      {
          DWORD lLastStatus(GetLastError());
          OHTRACE(Trace::eTAlways, L"Pipe Status: " &lt;&lt; (unsigned int)lLastStatus);
          break;
      }
      if (ERROR_PIPE_BUSY != GetLastError())
      {
          DWORD lLastStatus(GetLastError());
          OHTRACE(Trace::eTAlways, L"Pipe Status: " &lt;&lt; (unsigned int)lLastStatus);
          break;
      }
      if (!WaitNamedPipe(L"MyPipe", 20000))
      {
          DWORD lLastStatus(GetLastError());
          OHTRACE(Trace::eTAlways, L"WPipe Status: " &lt;&lt; (unsigned int)lLastStatus);
      }
  </code></pre>
  
  <p>When this function is called the pipe creation fails with error code 231 (i.e Pipe busy). I don't understand why the pipe is busy and what is the correct way to create pipe? What should be the post checks and pre-checks before going forward to creating a pipe?</p>