Esempio n. 1
0
        public Form1()
        {
            InitializeComponent();

            String HostName = Dns.GetHostName();
            IPHostEntry ipEntry = Dns.GetHostByName(HostName);
            IPAddress[] addresses = ipEntry.AddressList;
            IPAddress addr = IPAddress.Parse("127.0.0.1");
            foreach (IPAddress a in addresses){
                if (a.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                {
                    addr = a;
                    break;
                }
            }
            Basic = new BasicClient(19999, 9587, addr);

            client = new TCPClient(Basic);
            serv = new TCPServer(Basic);
               //serv = new SelectServer(Managers.ROUTING_TYPE.onion, DateTime.Parse("00:00:05"), 19999, 1456, addr);
            udp_serv = new UDPServer(Basic, HostName, serv.getpublickey());

            serv.Run();         //Запускаем TCP сервер обработки
            udp_serv.Run();     //Запускаем UDP сервер рассылки IP
            //MessageBox.Show("UDP Run");

            //MessageBox.Show("Server Run");
            serv.NewMessageEvent += new NewMessageDelegate(Handler);
            client.ScanHosts(1); //Поиск доступных хостов
            //MessageBox.Show("Scanhosts Run");
            HostsToPictures();

            //client.SendString("Приветик", new Workstation(serv.CurrentIP, serv.getpublickey()));
            //client.SendString("Ты тут?", new Workstation(serv.CurrentIP, serv.getpublickey()));
        }