Griffin.Framework 是 .NET 的高性能网络框架。
示例代码:
public class Server{ private readonly ChannelTcpListener _server; public Server() { _server = new ChannelTcpListener(); _server.MessageReceived += OnMessage; _server.ClientConnected += OnClientConnected; _server.ClientDisconnected += OnClientDisconnected; } public int LocalPort { get { return _server.LocalPort; } } public void Start() { _server.Start(IPAddress.Any, 0); } private void OnClientConnected(object sender, ClientConnectedEventArgs e) { Console.WriteLine("Got connection from client with ip " + e.channel.RemoteEndPoint); } private void OnClientDisconnected(object sender, ClientDisconnectedEventArgs e) { Console.WriteLine("Disconnected: " + e.Channel.RemoteEndpoint); } private void OnMessage(ITcpChannel channel, object message) { Console.WriteLine("Server received: " + message); channel.Send(Encoding.ASCII.GetBytes("Hello world")); }}