Exemplo n.º 1
0
        private void Client()
        {

            SocketWatcher c_w = new SocketWatcher(20);
            c_w.Synchronous = true;

            // Note: must have a client cert in your IE cert store.
            X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
            store.Open(OpenFlags.ReadOnly);

            if (store.Certificates.Count > 0)
            {
                c_w.LocalCertificate = store.Certificates[0];
            }
            else
            {
                lock (done)
                {
                    errorMessage = "There were no certificates in the Windows Certificate Store.";
                    succeeded = false;
                    Monitor.Pulse(done);
                }

                return;
            }
            c_w.CreateConnectSocket(this, a, true, "localhost");
        }
Exemplo n.º 2
0
        [Test] public void Test_Write()
        {
            SocketWatcher w = new SocketWatcher(20);
            Address a = new Address("127.0.0.1", 7001);
            a.Resolve();

            AsyncSocket listen = w.CreateListenSocket(this, a);
            listen.RequestAccept();

            AsyncSocket connect;
            lock (done)
            {
                connect = w.CreateConnectSocket(this, a);
                bool NoTimeout = Monitor.Wait(done, new TimeSpan(0, 0, 30));

                Assert.IsTrue(NoTimeout, "The read command didn't complete in time.");
                Assert.IsTrue(succeeded, errorMessage);
            }

            Assert.AreEqual("5678901234", success);
            connect.Close();
            listen.Close();
        }