title: CreateFile error trying to open pipe
body: <p>I am trying to create a demonstration client/server application using named pipes on two Windows 7 machines, but cannot get this to work. The two machines, let's call them server and laptop, are both connected to an ethernet switch which is in turn connected to a cable modem.  Both machines can see the internet, and both machines show up in the Windows network map. So I think they are correctly networked.</p>
  
  <p>I am writing in Visual C++ and am basically copying the sample code on MSDN for a named pipe server and client.  On my server, I call CreateNamedPipe() using the pipe name:</p>
  
  <pre><code>\\.\pipe\MyServerName
  </code></pre>
  
  <p>On the client, I call CreateFile with the pipe name of:</p>
  
  <pre><code>\\&lt;machine&gt;\pipe\MyServerName
  </code></pre>
  
  <p>where "machine" is configurable.  If I run the server and client on the same machine, and for machine use either "." or "POWEREDGE" (the name of my server machine according to Windows), the two programs communicate fine.</p>
  
  <p>Now I go to my laptop and run the client software.  I use "POWEREDGE" as the machine name. CreateFile fails with GetLastError=1 ("Incorrect Function" apparently).</p>
  
  <p>Any ideas about what could be going wrong here?</p>
  
  <p>In response to requests, here is the actual code:</p>
  
  <pre><code> // CLIENT SIDE
   // note: value of gLKServer is "POWEREDGE"
   char PipeName[256]="";
   wsprintf(PipeName,"\\\\%s\\pipe\\LKServer", gLKServerName);
  
   while (TRUE) {
     hPipe = CreateFile( 
     PipeName,   // pipe name 
     GENERIC_READ |  // read and write access 
     GENERIC_WRITE, 
     0,              // no sharing 
     NULL,           // default security attributes
     OPEN_EXISTING,  // opens existing pipe 
     0,              // default attributes 
     NULL);          // no template file 
  
     if (hPipe != INVALID_HANDLE_VALUE) {
       break; 
     }
  
     // Exit if an error other than ERROR_PIPE_BUSY occurs. 
  
     if (err=GetLastError() != ERROR_PIPE_BUSY) 
      {
        printf("CreateFile error %lu\n", err); 
      }
      ...
  
   // SERVER SIDE
   char PipeName[256]="\\\\.\\pipe\\LKServer"; 
    hPipe = CreateNamedPipe( 
        PipeName,             // pipe name 
        PIPE_ACCESS_DUPLEX,       // read/write access 
        PIPE_TYPE_MESSAGE |       // message type pipe 
        PIPE_READMODE_MESSAGE |   // message-read mode 
        PIPE_WAIT,                // blocking mode 
        PIPE_UNLIMITED_INSTANCES, // max. instances  
        BUFSIZE,                  // output buffer size 
        BUFSIZE,                  // input buffer size 
        0,                        // client time-out 
        NULL);                    // default security attribute 
  </code></pre>