static void Main(string[] args) { var server = new ServerFactory(); using (server.Create(App, 8080)) { Console.WriteLine("Running server on http://localhost:8080/"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); } }
public void ServerWillCloseSocket() { var server = new ServerFactory().Create((env, result, fault) => { }, 56566); server.Dispose(); Assert.Throws<SocketException>(() => { var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); socket.Connect("localhost", 56566); socket.Close(); }); }
//private static IDisposable StartupWorkingTitleApp() //{ // var server = new Server((req, resp) => // { // resp.Write("Hello, again, world"); // resp.End(); // }); // server.Listen(8081, null); // return server; //} private static IDisposable StartupNancyApp() { var builder = new AppBuilder(); builder .Use(SetResponseHeader, "X-Server", "Dragonfly") .Use(ShowCalls) .UseWebSockets("/socketserver", OnConnection) .UseChunked() .RunNancy(); var app = builder.Materialize<AppDelegate>(); var server = new ServerFactory(new StdoutTrace()).Create(app, 8080); Console.WriteLine("Running on localhost:8080"); return server; }