• This repository has been archived on 08/Oct/2021
  • Stars
    star
    929
  • Rank 47,224 (Top 1.0 %)
  • Language
    C#
  • License
    MIT License
  • Created about 9 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A high performance websocket server library powering Stack Overflow.

Welcome to StackExchange.NetGain!

Warning: reduced maintenance

A few things have changed since this library was written:

  • "pipelines" have become the new hotness for high performance low overhead IO code - see my 3-and-a-bit-part series here
  • "Kestrel", combined with pipelines, now provides a great hosting experience for high volume servers
  • HTTP/2 (and above) have reduced the usefulness of web-sockets (one of the main drivers for me and NetGain), since the web-sockets drafts for HTTP/2 never really "took"

As of late 2018, Stack Overflow (Stack Exchange) have migrated away from NetGain, instead using Kestrel's inbuilt web-socket support over HTTP/1.*; it is entirely possible that as we delve more into HTTP/2, we look more in the direction of SSE (EventSource).

So: we're not actively working with, or working on, this library. If you have a burning desire to take it further as an official maintainer (perhaps with some tweaks to naming, obviously) - let me know!


NetGain supports:

  • RFC 6455
  • all draft versions of the RFC (between hixie-76 and v13, aka RFC 6455)
  • hixie-76/hybi-00
  • fixes for various browsers with slightly broken implementations

Build

StackExchange.NetGain is built as a single assembly, StackExchange.NetGain.dll.

NuGet Gallery

StackExchange.NetGain is available on the [NuGet Gallery]

  • [NuGet Gallery: stackexchange.netgain]

You can add StackExchange.NetGain to your project with the NuGet Package Manager, by using the following command in the Package Manager Console.

PM> Install-Package StackExchange.NetGain

WebSocket Server Example

using System;
using System.Net;
using StackExchange.NetGain;
using StackExchange.NetGain.WebSockets;

namespace Example
{
  public class Program
  {
    public static void Main (string[] args)
    {
		IPEndPoint endpoint = new IPEndPoint(IPAddress.Loopback, 6002);
		using(var server = new TcpServer())
		{
			server.ProtocolFactory = WebSocketsSelectorProcessor.Default;
			server.ConnectionTimeoutSeconds = 60;
			server.Received += msg =>
			{
				var conn = (WebSocketConnection)msg.Connection;
				string reply = (string)msg.Value + " / " + conn.Host;
				Console.WriteLine("[server] {0}", msg.Value);
				msg.Connection.Send(msg.Context, reply);
			};
			server.Start("abc", endpoint);
			Console.WriteLine("Server running");

			Console.ReadKey();
		}
		Console.WriteLine("Server dead; press any key");
		Console.ReadKey();
      }
    }
  }
}

More Repositories

1

blackbox

Safely store secrets in Git/Mercurial/Subversion
Go
6,614
star
2

StackExchange.Redis

General purpose redis client
C#
5,791
star
3

dnscontrol

Infrastructure as code for DNS!
Go
2,915
star
4

Stacks

Stack Overflowโ€™s Design System
Less
589
star
5

wmi

WMI for Go
Go
426
star
6

pagedown

The Markdown editor and converter used on Stack Overflow and the other Stack Exchange sites
JavaScript
413
star
7

StackExchange.DataExplorer

Stack Exchange Data Explorer
JavaScript
348
star
8

Stacks-Editor

Stack Overflow's Combination Rich Text / Markdown Editor
TypeScript
324
star
9

MarkdownSharp

Open source C# implementation of Markdown processor, used by Stack Overflow.
C#
241
star
10

stack-blog

Stack Overflow Blog
HTML
237
star
11

StackExchange.Utils

Utility class packages used at Stack Exchange...but on NuGet!
C#
196
star
12

httpunit

httpUnit tests compliance of web and net servers with desired output.
Go
163
star
13

StackExchange.Precompilation

Roslyn based csc.exe and aspnet_compiler.exe replacement with metaprogramming hooks for ASP.NET MVC projects from the pre-DNX era
C#
151
star
14

StackExchange.Metrics

A .NET client to send metrics to a variety of metrics backends
C#
136
star
15

Stacks-Icons

Authoring tools for Stack Overflow's shared icon set.
TypeScript
35
star
16

stackegg

The core game logic of Stack Overflow's April 1st 2015 game, StackEgg.
C#
30
star
17

NRediSearch

C#
27
star
18

mayflower

A simple MS SQL Server database migrator using Node.js and TDS.
JavaScript
26
star
19

StackID

An OpenID provider implemented for the Stack Exchange network, built on top of dotNetOpenAuth.
C#
20
star
20

stackexchange.github.com

Source for stackexchange.github.com
HTML
19
star
21

unikong

Stack Overflow's April 1, 2016 game
JavaScript
16
star
22

haproxy-kubefigurator

Dynamic haproxy configuration for Kubernetes services
Go
14
star
23

RyuJIT-TailCallBug

Tail Call Parameter Corruption Repro for .Net 4.6
C#
12
star
24

signalfx-powershell

This is a PowerShell wrapper around the SignalFx API
PowerShell
10
star
25

mof

Package mof parses and marshals Managed Object Format (MOF) structures
Go
9
star
26

pat

A wrapper for "puppet agent --test"
Go
9
star
27

apca-check

Axe rules to check against APCA bronze and silver+ conformance levels.
TypeScript
8
star
28

stackexchange-superfirewall

A facade for firewall::firewall{} that adds enhanced functionality.
Puppet
7
star
29

browserslist-viewer

Static site to parse and display a browserslist string
TypeScript
6
star
30

Stacks-TagHelpers

A set of .Net Core Tag Helpers for use with Stacks
C#
5
star
31

stacks-utils

A monorepo containing a collection of Stacks config files and other utilities
JavaScript
3
star
32

DesignSprint

This repository was used for building a Stack Overflow Talent exploratory design sprint.
HTML
2
star
33

sre-log-1

1
star
34

marketing-resources

1
star
35

terraform-provider-stackoverflow

Terraform Provider for Stack Overflow
Go
1
star