コード例 #1
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                return;
            }

            Console.WriteLine("writer starts");
            byte[] one = new byte[100000];
            GenericProxy <CacheStream.IIOHelper> p = null;

            p = new SimpleIPC.GenericProxy <CacheStream.IIOHelper>(new SimpleIPC.Windows.SIPCProxy("cachestreamreader"));
            if (args[0] == "1")
            {
                Console.WriteLine("******System Cache Read Write Demo*******");
                CacheStream.IOHelper ioh = new CacheStream.IOHelper(@"test1.dat");
                Console.WriteLine("created d:\\test1.dat on system cache");
                for (int i = 0; i < one.Length; ++i)
                {
                    one[i] = 1;
                }

                bool bret = ioh.Write(one, 0, one.Length);
                Console.WriteLine("Wrote 100000 bytes with 1");
                Console.WriteLine("Sending IPC call to the Reader");
                p.Proxy.WroteBytes(Process.GetCurrentProcess().Id, ioh.hImageFile, 0, one.Length);
                Console.WriteLine("Sleeping for 5 seconds");
                System.Threading.Thread.Sleep(5000);
                ioh.Read(one, 0, one.Length);
                Console.WriteLine("read {0} bytes with {1}", one.Length, one[0]);
            }
            else
            {
                Console.WriteLine("\n\n******ReadProcessMemory WriteProcessMeory Demo*******");
                for (int i = 0; i < one.Length; ++i)
                {
                    one[i] = 3;
                }
                GCHandle handle = GCHandle.Alloc(one, GCHandleType.Pinned);
                Console.WriteLine("Wrote 100000 bytes with 3");
                Console.WriteLine("Sending IPC call to the Reader");
                p.Proxy.WroteMemBytes(Process.GetCurrentProcess().Id, handle.AddrOfPinnedObject(), one.Length);
                Console.WriteLine("Sleeping for 5 seconds");
                System.Threading.Thread.Sleep(5000);
                Console.WriteLine("Remote Read 100000 bytes with {0}", one[0]);
                handle.Free();
                p.Dispose();
            }
            Console.WriteLine("press any key to stop");
            Console.ReadKey();
            Console.WriteLine("writer stops");
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: rvvyas/TechBlog
        static void namedobjectclienttest()
        {
            testclient tc = new testclient();

            SimpleIPC.NamedObject.SIPCServer t1 = new SimpleIPC.NamedObject.SIPCServer("namedclient", tc);
            t1.Start();
            Console.WriteLine("namedclient running");
            var p      = new SimpleIPC.GenericProxy <Example.ICallInterface>(new SimpleIPC.NamedObject.SIPCProxy("namedserver"));
            int ticket = 0;

            Console.WriteLine("calling server : register(veda)");
            string s = p.Proxy.register("veda", "namedclient", out ticket);

            Console.WriteLine("result of register call:{0}, Ticket:{1}", s, ticket);
            Console.ReadKey();
            p.Dispose();
            t1.Stop();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: rvvyas/TechBlog
        static void windowsclienttest()
        {
            testclient tc = new testclient();
            var        t1 = new SimpleIPC.Windows.ServerContainer();

            t1.Start();
            t1.CreateServer(new SimpleIPC.Windows.SIPCServer("winclient", tc));
            Console.WriteLine("winclient running");
            var p = new SimpleIPC.GenericProxy <Example.ICallInterface>(new SimpleIPC.Windows.SIPCProxy("winserver"));

            int ticket = 0;

            Console.WriteLine("calling server : register(veda)");
            string s = p.Proxy.register("veda", "winclient", out ticket);

            Console.WriteLine("result of register call:{0}, Ticket:{1}", s, ticket);
            Console.ReadKey();
            p.Dispose();

            t1.Stop();
        }