Beispiel #1
0
        public void InvalidChallengeTest()
        {
            // challenge that will (most likely) not fit with the keys of the handshake
            var challenge = new ArraySegment<byte>(new byte[] {1,3,3,4,5,6,7,8});

            var hs = new ExtendedClientHandshake()
                {
                    Origin = "testproject",
                    Host = "localhost:8181",
                    ResourcePath = "/test",
                    ChallengeBytes = challenge // wrong challenge
                };

            hs.ChallengeBytes = challenge;
            var client = new ClientSocket(hs);
            Thread.Sleep(1000);

            Assert.IsTrue(TestSocket.DisconnectedCalled, "socket didn't disconnect when it should have");
        }
Beispiel #2
0
        public void InvalidChallengeTest()
        {
            // challenge that will (most likely) not fit with the keys of the handshake
            var challenge = new ArraySegment <byte>(new byte[] { 1, 3, 3, 4, 5, 6, 7, 8 });

            var hs = new ExtendedClientHandshake()
            {
                Origin         = "testproject",
                Host           = "localhost:8181",
                ResourcePath   = "/test",
                ChallengeBytes = challenge     // wrong challenge
            };

            hs.ChallengeBytes = challenge;
            var client = new ClientSocket(hs);

            Thread.Sleep(1000);

            Assert.IsTrue(TestSocket.DisconnectedCalled, "socket didn't disconnect when it should have");
        }
Beispiel #3
0
        public ClientSocket(ExtendedClientHandshake hs)
        {
            Handshake = hs;
            Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);

            var tmp = Handshake.Host.Split(':');
            var port = 81;
            var host = Handshake.Host;
            if (tmp.Length > 1)
            {
                port = Int32.Parse(tmp[1]);
                host = tmp[0];
            }

            Socket.Connect(host, port);
            SendHandshake();
            if (!ReadHandshake())
            {
                Socket.Close();
            }
        }
Beispiel #4
0
        public ClientSocket(ExtendedClientHandshake hs)
        {
            Handshake = hs;
            Socket    = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);

            var tmp  = Handshake.Host.Split(':');
            var port = 81;
            var host = Handshake.Host;

            if (tmp.Length > 1)
            {
                port = Int32.Parse(tmp[1]);
                host = tmp[0];
            }

            Socket.Connect(host, port);
            SendHandshake();
            if (!ReadHandshake())
            {
                Socket.Close();
            }
        }