예제 #1
0
        private void crackButton_Click(object sender, EventArgs e)
        {
            int linkID = Int32.Parse(textBox1.Text);

            CommandLibrary.Link l = new CommandLibrary.Link();
            l.linkID = linkID;
            string destination = null;

            if (linkID == 10)
            {
                destination = "A:SN1:SN4:LRM";
            }
            if (linkID == 3 || linkID == 4 || linkID == 5)
            {
                destination = "A:SN1:SN17:LRM";
            }
            if (linkID == 8)
            {
                destination = "B:SN2:SN5:LRM";
            }
            if (linkID == 9 || linkID == 6 || linkID == 1)
            {
                destination = "B:SN2:LRM";
            }
            if (linkID == 0 || linkID == 1 || linkID == 2 || linkID == 7 || linkID == 6)
            {
                destination = "A:SN1:LRM";
            }


            IPEndPoint ipe     = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 60000);
            Socket     handler = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

            handler.Connect("127.0.0.1", 50000);

            CommandLibrary.Command message = new CommandLibrary.Command("Link Delete");
            message.linkList = new List <CommandLibrary.Link>();
            l.usedSlots.Add(1); //Test!!!!!
            l.usedSlots.Add(2);
            message.linkList.Add(l);
            message.sourceId      = "Cracker";
            message.destinationId = destination;
            message.deletedLinkId = linkID;


            using (var stream = new NetworkStream(handler))
            {
                BinaryFormatter bformatter = new BinaryFormatter();
                bformatter.Serialize(stream, message);
                stream.Flush();
                stream.Close();
            }
            handler.Close();
        }
예제 #2
0
        public void Reader()
        {
            string[]      split  = self.ReturnName().Split(new char[] { ':' });
            string        join   = string.Join("", split);
            var           path   = System.Configuration.ConfigurationManager.AppSettings[join + "LRM"];
            XmlTextReader reader = new XmlTextReader(path);
            int           linkID;
            string        Object1;
            string        Object2;
            int           portObject1;
            int           portObject2;
            int           length;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    if (reader.Name == "link")
                    {
                        linkID      = Int32.Parse(reader.GetAttribute("id"));
                        Object1     = reader.GetAttribute("o1");
                        Object2     = reader.GetAttribute("o2");
                        portObject1 = Int32.Parse(reader.GetAttribute("p1"));
                        portObject2 = Int32.Parse(reader.GetAttribute("p2"));
                        length      = Int32.Parse(reader.GetAttribute("len"));
                        CommandLibrary.Link l = new CommandLibrary.Link(linkID, Object1, Object2, portObject1, portObject2, length);
                        l.usedSlots = new List <int>();
                        linkList.Add(l);
                    }
                    break;

                case XmlNodeType.Text:
                    Console.WriteLine(reader.Value);
                    break;

                case XmlNodeType.EndElement:
                    if (reader.Name == "link")
                    {
                        Console.WriteLine("End mark reached");
                    }
                    break;
                }
            }
        }