title: Named Pipe messages not getting through (Windows / C++)
body: <p>Attempting to read from a named pipe. As far as I know the client is connecting ok and sending. Considering the code is taken from solutions on here, i'm struggling to see where I have messed up.
  Readfile doesn't seem to get anything. It doesn't return.
  If you close the connection at the client end 0 is returned.</p>
  
  <p>Any Ideas?</p>
  
  <pre><code>DWORD WINAPI LogManager::LogCollector(LPVOID args)
  {
      LogMan *LogMgr = (LogMan*)args;
      int run; LogMgr -&gt;GetValue(run);
  
      while (run != LogMan::eNONE) {
          HANDLE pipe = CreateNamedPipe("\\\\.\\pipe\\RCLogPipe", PIPE_ACCESS_INBOUND , PIPE_WAIT, 1, 1024, 1024, 120 * 1000, NULL);
          ConnectNamedPipe(pipe, NULL);
          if (pipe == INVALID_HANDLE_VALUE){
              CloseHandle(pipe);
              return -1;
          }
          char line[1024];
          DWORD numRead = 0;
          if (!ReadFile(pipe, line, 1024, &amp;numRead, NULL) || numRead &lt; 1) return -1;
          LogMgr -&gt;Write(line);
          LogMgr -&gt;GetValue(run);
          CloseHandle(pipe);
      }
      return 0;
  }
  </code></pre>
  
  <p>Client</p>
  
  <pre><code>var client = new NamedPipeClientStream("RCLogPipe");
  client.Connect();
  StreamWriter writer = new StreamWriter(client);
  if (client.CanWrite) writer.WriteLine("Hello\n");
  </code></pre>