Esempio n. 1
0
        public static void Main(string[] args)
        {
            bool exit = false;

            Console.WriteLine("Press any key to Connect to Server");
            Console.ReadKey(true);
            Client client = new Client(new IPEndPoint(IPAddress.Any, 56239));

            client.PSKIdentities.AddIdentity(Encoding.UTF8.GetBytes("oFIrQFrW8EWcZ5u7eGfrkw"), HexToBytes("7CCDE14A5CF3B71C0C08C8B7F9E5"));
            //client.LoadCertificateFromPem(@"Client.pem");
            client.SupportedCipherSuites.Add(TCipherSuite.TLS_PSK_WITH_AES_128_CCM_8);
            client.ConnectToServer(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 5684));
            Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e)
            {
                e.Cancel = true;
                exit     = true;
            };
            Console.WriteLine();
            Console.WriteLine("Press Ctrl+C to stop the client. Any other characters are send to server");
            Console.WriteLine();
            while (!exit)
            {
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo pressedKey = Console.ReadKey(true);
                    client.Send(Encoding.UTF8.GetBytes(pressedKey.KeyChar.ToString()));
                }
            }
            client.Stop();
        }