Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void HTTPListener()
- {
- // Create a listener.
- try {
- HttpListener listener = new HttpListener();
- // Add the prefixes from UI.
- listener.Prefixes.Add(URL_field);
- while (true) {
- listener.Start();
- // Note: The GetContext method blocks while waiting for a request.
- HttpListenerContext context = listener.GetContext();
- HttpListenerRequest request = context.Request;
- using (var bodyStream = request.InputStream)
- {
- using (System.IO.StreamReader reader = new System.IO.StreamReader(bodyStream, request.ContentEncoding))
- {
- AssignText(reader.ReadToEnd());
- }
- }
- }
- }
- catch (Exception e) {
- string err_msg = "On client connect exception " + e;
- ans = err_msg.ToString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement