NetGain supports:
StackExchange.NetGain is built as a single assembly, StackExchange.NetGain.dll.
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
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();
}
}
}
}