Alon
Alon

Reputation: 1804

Creating C++ Named Pipes for Intranet hosts

I've been trying to create a named pipes using microsoft code:

http://code.msdn.microsoft.com/windowsdesktop/CppNamedPipeClient-a88eb958

I also took security token from elsewhere:

SECURITY_ATTRIBUTES sa;
    sa.lpSecurityDescriptor = (PSECURITY_DESCRIPTOR)malloc(
        SECURITY_DESCRIPTOR_MIN_LENGTH);
    InitializeSecurityDescriptor(sa.lpSecurityDescriptor, 
        SECURITY_DESCRIPTOR_REVISION);
    // ACL is set as NULL in order to allow all access to the object.
    SetSecurityDescriptorDacl(sa.lpSecurityDescriptor, TRUE, NULL, FALSE);
    sa.nLength = sizeof(sa);
    sa.bInheritHandle = TRUE;

I want to declare the server instead of locally, on my ip, for it to be accsessed by other pcs on the intranet:

#define SERVER_NAME         L"10.12.13.122" ("." works)
#define PIPE_NAME           L"SamplePipe"
#define FULL_PIPE_NAME      L"\\\\" SERVER_NAME L"\\pipe\\" PIPE_NAME

Has anyone declared this for C++ before? this is refusing to create the named pipe...

Upvotes: 0

Views: 300

Answers (1)

user207421
user207421

Reputation: 310840

0x7B is ERROR_INVALID__NAME. "The pipe server cannot create a pipe on another computer, so CreateNamedPipe must use a period for the server name, as shown in the following example \\.\pipe\PipeName": see MSDN. Don't forget to double the backslashes for string literals.

Upvotes: 1

Related Questions