Exemplo n.º 1
0
        //asdasdasda
        public void  startHttpServer()
        {
            HttpListener listener = null;

            try
            {
                listener = new HttpListener();
                listener.Prefixes.Add("http://localhost:1300/simpleserver/");
                listener.Start();
                while (true)
                {
                    HttpListenerContext context = listener.GetContext();
                    string msg = actualPort;
                    context.Equals("PORT");

                    context.Response.ContentLength64 = Encoding.UTF8.GetByteCount(msg);
                    context.Response.StatusCode      = (int)HttpStatusCode.OK;
                    using (Stream stream = context.Response.OutputStream)
                    {
                        using (StreamWriter writer = new StreamWriter(stream))
                        {
                            writer.Write(msg);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.Write("chyba " + e);
            }
        }