示例#1
0
        private SNMPJsonPacket sendRequest(string oid)
        {
            SnmpV1Packet   packet     = this.GetRequest((string)oid);
            SNMPJsonPacket packetJson = new SNMPJsonPacket(packet.Pdu.VbList[0].Oid.ToString(), packet.Pdu.VbList[0].Value.ToString(), packet.Pdu.VbList[0].Type.ToString());

            return(packetJson);
        }
示例#2
0
        private void ListenThread(Object client)
        {
            TcpClient clienttmp = (TcpClient)client;
            //BinaryReader reader = new BinaryReader(clienttmp.GetStream());
            StreamReader read = new StreamReader(clienttmp.GetStream());
            //BinaryWriter writer = new BinaryWriter(clienttmp.GetStream());
            StreamWriter write = new StreamWriter(clienttmp.GetStream());

            while (true)
            {
                String received_data = read.ReadLine();
                Console.WriteLine(received_data);
                SNMPJsonPacket packet = sendRequest(received_data);
                if (packet.value != null)
                {
                    try
                    {
                        write.WriteLine(packet.value.ToString());
                        Console.WriteLine("wyslano " + packet.value);
                    }catch (IOException e)
                    {
                        Console.WriteLine(e.Data);
                    }
                }
            }

            // reader.Close();
        }