2 Questions about named channels

Hi, I have a couple of questions about using named pipes.

Firstly, when I tried to configure the pipeline server, I noticed that if I use the code below .. at the end of the first client to connect, the server becomes unavailable, DO NOT REMAIN that I will complete all this after a while (true), did I do it right? or should each server be active only once and then die?

using (NamedPipeServerStream pipeServerStream = new NamedPipeServerStream(pipeName, PipeDirection.In, 1, transmissionMode))
{
    pipeServerStream.WaitForConnection();

    using (StreamReader sr = new StreamReader(pipeServerStream))
    {
        string message = null;

        do
        {
            message = sr.ReadLine();
            OnPipeCommunicationHandler(new IPCData() { Data = message });
        }
        while (message != null);
    }
} 

Secondly, I also had to unscrew the server on my own thread. If I do not, my application will not be available. This is normal? Did I do it right? It seemed to me that I read somewhere that under the hood namedpipeserverstream creates its own stream for itself, but I can not see that it is.

Thanks!

+3
1

, , . ( , ), , , .

, , ( ), , , , ,

+3

Source: https://habr.com/ru/post/1722901/


All Articles