ネットワークを介してC#で名前付きパイプをセットアップする正しい方法は何ですか?
現在、「クライアント」と「サーバー」の 2 台のマシンがあります。
サーバーは、次の方法でパイプをセットアップします。
NamedPipeServerStream pipeServer = new NamedPipeServerStream(
"pipe",
PipeDirection.InOut,
10,
PipeTransmissionMode.Byte,
PipeOptions.None)
pipeServer.WaitForConnection();
//... Read some data from the pipe
クライアントは、次の方法で接続をセットアップします。
NamedPipeClientStream pipeClient = new NamedPipeClientStream(
"server",
"pipe",
PipeDirection.InOut);
pipeClient.Connect(); //This line throws an exception
//... Write some data to the pipe
「\\server」に移動することで、「サーバー」マシンにネットワーク上でアクセスできます。
プログラムを実行するたびに、「パスへのアクセスが拒否されました」という System.UnauthorizedAccessException が発生します。ローカル マシンでサーバーとクライアントを実行し、「.」に接続しようとすると、コードは正常に動作します。クライアントと。