1
2つのWindows PC間で名前付きパイプ経由でメッセージを送信しようとしています。 CreateNamedPipe
を呼び出すと、ローカルにすべて正常に動作します。ホスト名を"\\\\.\\pipe\\testpipename"
から"\\\\myHostname\\pipe\\testpipename"
に変更すると、ERROR_INVALID_NAME(123)
がgetLastError()
になります。ネットワーク上の名前付きパイプ無効名エラー
これは私のコードです:
BOOL fConnected = FALSE;
DWORD dwThreadId = 0;
HANDLE hPipe = INVALID_HANDLE_VALUE, hThread = NULL;
LPTSTR pipeName = /*nullptr*/ TEXT("\\\\myHostname\\pipe\\testpipename");
SECURITY_ATTRIBUTES sa = { 0 };
SECURITY_DESCRIPTOR sd = { 0 };
InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
sa.bInheritHandle = false;
sa.lpSecurityDescriptor = &sd;
sa.nLength = sizeof(sa);
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
255, // output buffer size
255, // input buffer size
0, // client time-out
&sa); // default security attribute
if (hPipe == INVALID_HANDLE_VALUE)
{
cout << GetLastError();
return -2;
}
cout << "Waiting for client to connect!" << endl;
//waiting for client to connect
fConnected = ConnectNamedPipe(hPipe, NULL) ?
TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
cout << "Client connected! YEAH" << endl;
私の推測では、パイプ名が無効であるということですが、私はなぜ知っているドント。何か案は?
あなたはホスト名の代わりにIPアドレスを使用しようとしましたか? – fsp
@ user3549596ええ、同じエラーが発生します。 – Strizzi
はばかげて聞こえるかもしれませんが、パイプ名が正しく、サーバー上でポート445の受信が許可されていますか? – fsp