public ActionResult StatusNetwork()
 {
     IPEndPointTestModel model = new IPEndPointTestModel
     {
         HostName = GetHostName(),
         Port = GetPort()
     };
     return View(model);
 }
        public ActionResult StatusNetwork(IPEndPointTestModel model)
        {
            model.Message = null;
            TcpClient Zebraclient = new TcpClient();
            try
            {
                Zebraclient.SendTimeout = 500;
                Zebraclient.ReceiveTimeout = 500;
                Zebraclient.Connect(model.HostName, model.Port);
                if (Zebraclient.Connected)
                {
                    //send and receive illustrated below
                    NetworkStream mynetworkstream;
                    StreamReader mystreamreader;
                    StreamWriter mystreamwriter;
                    mynetworkstream = Zebraclient.GetStream();
                    mystreamreader = new StreamReader(mynetworkstream);
                    mystreamwriter = new StreamWriter(mynetworkstream);
                    string commandtosend = "~HS";
                    mystreamwriter.WriteLine(commandtosend);
                    mystreamwriter.Flush();
                    char[] mk = null;
                    mk = new char[100];
                    mystreamreader.Read(mk, 0, mk.Length);
                    string data1 = new string(mk);
                    model.Message = "Response = "+data1;
                    Zebraclient.Close();
                }
                else
                {
                    ModelState.AddModelError("", "Not Connected");
                }
            }
            catch(Exception e)
            {
                ModelState.AddModelError("", e.Message);
            }

            return View(model);
        }