Code Monkey home page Code Monkey logo

nowin's Introduction

Nowin

Fast and scalable Owin Web Server in pure .Net 4.5 (it does not use HttpListener)

Current status is usable for testing, not for production, nobody did any security review, you have been warned. On Windows speed is better than NodeJs and in some cases even better than HttpListener.

Features it supports:

  • Http 1.0 and 1.1 clients uses SocketAsyncEventArgs in most optimal way you can found on the Internets
  • KeepAlive, untested pipelining, automatic chunked en/decoding of request and response
  • Everything strictly asynchronous and parallel automaticaly using all available cores
  • SSL using .Net SSL Stream so in theory it should be same secure
  • WebSockets in platform independent way! It buffers data so SignalR is more optimal on wire than current HttpListener on Win8.
  • Tracks currently connection counts and maximum allocated connections and allocates new as needed
  • One connection needs less than 20kb RAM and most of it is reused but never deallocated.
  • By default settings maximum size of request and response headers are 8KB.
  • Published in Nuget for easy use. No dependencies.

Sample: (uses Microsoft.Owin.Hosting nuget)

static class Program
{
    static void Main(string[] args)
    {
        var options = new StartOptions
        {
            ServerFactory = "Nowin",
            Port = 8080
        };

        using (WebApp.Start<Startup>(options))
        {
            Console.WriteLine("Running a http server on port 8080");
            Console.ReadKey();
        }
    }
}

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.Use(context =>
        {
            if (context.Request.Path == "/")
            {
                context.Response.ContentType = "text/plain";
                return context.Response.WriteAsync("Hello World!");
            }

            context.Response.StatusCode = 404;
            return Task.Delay(0);
        });
    }
}

Https sample using builder:

var builder = ServerBuilder.New().SetPort(8888).SetOwinApp(SomeOwinApp);
builder.SetCertificate(new X509Certificate2("certificate.pfx", "password"));
using (builder.Start())
{
    Console.WriteLine("Listening on port 8888. Enter to exit.");
    Console.ReadLine();
}

If running on OSX/Linux and MonoDevelop/Xamarin, to use the above sample please select external console in your project options by going to Options / Run / General / Run on external console

nowin's People

Contributors

bobris avatar jchannon avatar gabe-avila avatar chriseldredge avatar serialseb avatar

Watchers

James Cloos avatar Thunder Cheng avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.