title: Named pipe programs work on one computer, server stops working on different computer
body: <p>For a few days I've been trying to get a test-program running to send data from a 64-bit application to a 32-bit application via Named Pipes. On my Windows 8.1 laptop (64bit) the test-program in the code below runs perfectly fine. When I try to run the exact same code on a Windows 7 (64bit) desktop computer, the server side gets the pop-up 'pwrite.exe has stopped working'. This happens when I either compile it and run it on the desktop or when I run the executables (compiled on the laptop) on the desktop computer (just by copying the two .exe files). </p>
  
  <p>The strange thing is that the client side receives the value send via the named pipe in the first WriteFile operation, but it will not get the value from the second operation in the for-loop. So after the client side receives the correct value and displays it in the console window, the server side gets stuck. It could be that for some reason I don't have permission to write and the system realizes this after one operation, but I would expect an error related to permission, which is not the case. </p>
  
  <p>To give you a better idea:</p>
  
  <ul>
  <li><p>Both laptop and desktop computer accounts are running as Administrator. I tried to set the security level to the lowest level in the Control Panel.</p></li>
  <li><p>I disabled the Windows Firewall on the desktop computer</p></li>
  <li><p>'netstat -a' in the command window on both computers give under port 445, 135 and 137 'LISTENING', which I understood are the ports often used for Named Pipes.</p></li>
  <li><p>I'm using Visual Studio 2012</p></li>
  <li><p>Either the client and server side run independently without this problem occurring</p></li>
  <li><p>Desktop is running at 3.4GHz, laptop is running at 1.8 GHz</p></li>
  <li><p>Desktop has .NET framework 4.0, laptop has 4.5</p></li>
  </ul>
  
  <p>I think the solution must either be found in security settings or a problem with a-synchronization, so that is the direction of my search for days, but without success.</p>
  
  <p>Server:</p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;iostream&gt;
  #include &lt;sstream&gt;  
  #include &lt;string&gt;
  #include "globals.h"
  
  using namespace std;
  
  #define  THE_PIPE "\\\\.\\pipe\\testpipe"
  int main()
  {
  HANDLE pipe = CreateFile(THE_PIPE, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
  double i = 0;
  boolean r = true;
  
  while (r == true) {
  std::ostringstream ostr; 
  ostr &lt;&lt; i+0.000010; 
  std::string theNumberString = ostr.str(); 
  string message = theNumberString;
  WriteFile(pipe, message.c_str(), message.length() + 1, NULL, NULL); 
  cout &lt;&lt; GetLastError() &lt;&lt; endl;
  i++;    
      if (pipe == INVALID_HANDLE_VALUE)
  {
      cout &lt;&lt; "Error: " &lt;&lt; GetLastError();
  }
  }
  
  return 0;
  }
  </code></pre>
  
  <p>Client:</p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;iostream&gt;
  #include &lt;conio.h&gt;
  using namespace std;
  #define  THE_PIPE "\\\\.\\pipe\\testpipe"
  
  int main()
  {
  boolean t = true;
  char key = '\0';
  
  HANDLE pipe = CreateNamedPipe(THE_PIPE, PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED,      PIPE_WAIT, 1, 1024, 1024, 120 * 1000, NULL);  //FILE_SHARE_READ
  while (1) {
  
      if (_kbhit()) key = _getch();
      if (key == 'q') break;
  
  if (pipe == INVALID_HANDLE_VALUE)
  {
      cout &lt;&lt; "Error: " &lt;&lt; GetLastError();
  }
  
  char data[1024];
  DWORD numRead;
  
  ConnectNamedPipe(pipe, NULL);
  ReadFile(pipe, data, 1024, &amp;numRead, NULL);
  
  if (numRead &gt; 0){
      cout &lt;&lt; data &lt;&lt; endl;
  }
  }
  CloseHandle(pipe);
  }
  </code></pre>