private Start ( |
||
boundSocket | ||
return | void |
public void ServerShouldStopListening() { using ( var server = new EventHttpListener(r => r.Respond(System.Net.HttpStatusCode.OK, new Dictionary<string, string>(), new byte[0]))) { server.Start("127.0.0.1", _freePort); server.StopListeningAsync().Wait(); CheckPortIsStillFree(); } }
public void TestServerListening() { using ( var server = new EventHttpListener(r => r.Respond(System.Net.HttpStatusCode.OK, new Dictionary<string, string>(), new byte[0]))) { server.Start("127.0.0.1", _freePort); var wc = new WebClient(); wc.DownloadData(_urlBase); } CheckPortIsStillFree(); }
public void ServerShouldWaitForPendingRequests() { using ( var server = new EventHttpListener (r => ThreadPool.QueueUserWorkItem(_ => { Thread.Sleep(1000); r.Respond(HttpStatusCode.OK, new Dictionary<string, string>(), new byte[0]); }))) { server.Start ("127.0.0.1", _freePort); new WebClient().DownloadDataAsync(new Uri(_urlBase)); Thread.Sleep(100); var task = server.Shutdown(); Thread.Sleep(500); Assert.False(task.IsCompleted); Assert.True(task.Wait(4000)); } }
public void Start() { _listener = new EventHttpListener(RequestHandler); _listener.Start(_host, (ushort) _port); }
static void Main(string[] args) { var host = new EventHttpListener(Handler); host.Start(args[0], ushort.Parse(args[1]), int.Parse(args[2])); }