views:

143

answers:

1

I've got a simple design I'm trying to implement.

A single C++ based server app creates a write-only named pipe. Multiple clients (C++ or C#) connect as read-only and listen for status messages.

I have this working for local processes, but I am unable to connect a client on a different host to the server.

The server is running on XP SP2 (maybe SP3). The client is running on Win7.

 SECURITY_DESCRIPTOR sd;
 SECURITY_ATTRIBUTES sa;
 SID_IDENTIFIER_AUTHORITY siaWorldSidAuthority = SECURITY_WORLD_SID_AUTHORITY;
 PSID psidWorldSid = (PSID) LocalAlloc  (LPTR, GetSidLengthRequired(1));
 InitializeSid(psidWorldSid, &siaWorldSidAuthority, 1);
 *(GetSidSubAuthority(psidWorldSid, 0)) = SECURITY_WORLD_RID;
 InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
 SetSecurityDescriptorGroup(&sd, psidWorldSid, TRUE);
 ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
 sa.nLength = sizeof(SECURITY_ATTRIBUTES);
 sa.lpSecurityDescriptor = &sd;
 sa.bInheritHandle = FALSE;

 HANDLE hPipe = CreateNamedPipe(
  lpszPipename,    // name
  PIPE_ACCESS_OUTBOUND,  // 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 
  PIPE_TIMEOUT,    // client time-out 
  NULL /*&sa*/);      // no security attribute

replacing the NULL with &sa in the final param has no effect. The C# client code looks like this.

        SafeFileHandle pipeHandle = 
           CreateFile(
              pipeName,
              GENERIC_READ,
              0,
              IntPtr.Zero,
              OPEN_EXISTING,
              0,
              IntPtr.Zero);

What stupidly obvious thing am I missing here?

A: 

Have you checked your firewall? Is port 445 blocked?

Jeff Paquette
XP is running in a VM on the Win7 host. I believe that Windows Firewall is disabled both on the host and the VM. I believe the VM networking adapter isn't doing any filtering.Of course, the word "believe" is an important caveat here.
Joshua Muskovitz
On the other hand, I was having trouble earlier when both the client and server were on the same machine, but instead of having a pipe named "\\.\pipe\foo" I was using "\\12.34.56.78\pipe\foo" (well, with the actual IP address, of course) -- this seemed to have connection failures even when both processes were local.
Joshua Muskovitz
Josh, I found this KB article on using named pipes on XP. There's some setup involved... http://support.microsoft.com/kb/925890
Jeff Paquette