I use a C# HttpListener as follows...
private void CreateListener
{
HttpListener listener = null;
HttpListenerContext context = null;
HttpListenerRequest request = null;
HttpListenerResponse response = null;
string PortNumber = "9876";
string requestUrl;
Boolean listen = false;
try
{
if (listener == null)
{
listener = new HttpListener();
listener.Prefixes.Add("http://*:" + PortNumber + "/");
listener.Start();
listen = true;
while (listen)
{
try
{
context = listener.GetContext();
}
catch (Exception e)
{
listen = false;
}
if (listen)
{
request = context.Request;
requestUrl = request.Url.ToString();
// Process request and/or request Url
}
}
}
}
}
Basically listener.GetContext();
blocks until an HTTP request is received. You can then use request = context.Request
to retrive the HTTP request data and process it. You can then use context.Response
to return a response.
Fairly simple to implement and adapt.