Ejemplo n.º 1
0
        public static string ReceiveMsg(string serverName, string pipeName)
        {
            using (var client = new NamedPipeClientStream(serverName, pipeName,
                                                          PipeDirection.InOut, PipeOptions.None,
                                                          TokenImpersonationLevel.Impersonation))
            {
                client.Connect();

                var writer = new NamedPipeStreamWriter(client);
                writer.Write("GET data.xml");

                var reader = new NamedPipeStreamReader(client);
                return(reader.Read());
            }
        }
Ejemplo n.º 2
0
        public static void SendMsg(string pipeName, string msg)
        {
            using (var server = new NamedPipeServerStream(pipeName, PipeDirection.InOut))
            {
                server.WaitForConnection();

                var reader = new NamedPipeStreamReader(server);

                var clientsMsg = reader.Read();

                if (clientsMsg == "GET data.xml")
                {
                    var writer = new NamedPipeStreamWriter(server);

                    server.RunAsClient(() => { writer.Write(msg); });
                }
            }
        }