37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using TouchSocket.Core;
|
|
using TouchSocket.Sockets;
|
|
using TouchSocketTest;
|
|
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
CreateHostBuilder(args).Build().Run();
|
|
}
|
|
|
|
private static IHostBuilder CreateHostBuilder(string[] args) =>
|
|
Host.CreateDefaultBuilder(args)
|
|
.ConfigureServices((hostContext, services) => { ConfigureServices(services, hostContext); });
|
|
|
|
|
|
private static void ConfigureServices(IServiceCollection services, HostBuilderContext hostContext)
|
|
{
|
|
services.AddTcpService(config =>
|
|
{
|
|
config.SetListenIPHosts(9500)
|
|
.SetMaxCount(100000)
|
|
//.SetTcpDataHandlingAdapter(()=>new StandardFixedHeaderDataHandlingAdapter())
|
|
//.SetGetDefaultNewId(() => Guid.NewGuid().ToString())//定义ClientId的生成策略
|
|
.ConfigurePlugins(a =>
|
|
{
|
|
a.Add<TcpMonitor>();
|
|
a.Add<ServerMonitor>();
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|