title: Named Pipes between C# and Python
body: <p>I'm trying to create a two-way communication channel between two programs (one in Python and another in C#)</p>
  
  <p>When I create a named pipe between two C# programs or two Python programs, everything is OK, but when I try to (for example) connect to the C# server from Python code, it does not work:</p>
  
  <p>C# code:</p>
  
  <pre><code>NamedPipeServerStream server = new NamedPipeServerStream(
      "Demo", PipeDirection.InOut, 100, PipeTransmissionMode.Byte,
      PipeOptions.None, 4096, 4096)
  </code></pre>
  
  <p>If I use <code>win32pipe</code> in Python, code blocks on <code>ConnectNamedPipe</code> (it never returns)</p>
  
  
  
  <pre><code>p = win32pipe.CreateNamedPipe(
      r'\\.\pipe\Demo',
      win32pipe.PIPE_ACCESS_DUPLEX,
      win32pipe.PIPE_TYPE_BYTE | win32pipe.PIPE_WAIT,
      1, 65536, 65536,
      300,
      None)
  win32pipe.ConnectNamedPipe(p)
  </code></pre>
  
  <p>If I use open function, it just establishes a connection, but nothing occurs:</p>
  
  
  
  <pre><code>open( '\\\\.\\pipe\\Demo', 'r+b' )
  </code></pre>
  
  <p>Now if I close the Python program, C# server receives just one data item from Python and a <code>System.IO.IOException</code> raises with "Pipe is broken" message</p>
  
  <p>Am I doing anything wrong ? </p>