using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Net; using System.IO; using System.Diagnostics; namespace WebServer { class servernew { static void Main(string[] args) { HttpListener listner = null; try { listner= new HttpListener(); listner.Prefixes.Add("http://localhost:1300/"); listner.Start(); while(true) { Console.WriteLine("Waiting...."); HttpListenerContext context =listner.GetContext(); string msg = "Welcome to the server"; 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); } } Console.WriteLine("Message Sent....."); } } catch(WebException e) { Console.WriteLine(e.Status); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)