feat: Networking v3 using epoll/kqueue (#813)
* Replaces networking internals with epoll/kqueue
This commit is contained in:
parent
8eaa859332
commit
a845f8a1c0
14 changed files with 686 additions and 198 deletions
|
|
@ -84,6 +84,14 @@ namespace Server.Network
|
|||
Listeners = listeners.ToArray();
|
||||
}
|
||||
|
||||
public static void Shutdown()
|
||||
{
|
||||
foreach (var listener in Listeners)
|
||||
{
|
||||
listener.Server.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<IPEndPoint> GetListeningAddresses(IPEndPoint ipep) =>
|
||||
NetworkInterface.GetAllNetworkInterfaces().SelectMany(adapter =>
|
||||
adapter.GetIPProperties().UnicastAddresses
|
||||
|
|
@ -93,12 +101,19 @@ namespace Server.Network
|
|||
|
||||
public static TcpListener CreateListener(IPEndPoint ipep)
|
||||
{
|
||||
var listener = new TcpListener(ipep);
|
||||
listener.Server.ExclusiveAddressUse = false;
|
||||
var listener = new TcpListener(ipep)
|
||||
{
|
||||
Server =
|
||||
{
|
||||
LingerState = new LingerOption(false, 0),
|
||||
ExclusiveAddressUse = true,
|
||||
NoDelay = true
|
||||
}
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
listener.Start(8);
|
||||
listener.Start(32);
|
||||
return listener;
|
||||
}
|
||||
catch (SocketException se)
|
||||
|
|
@ -130,7 +145,6 @@ namespace Server.Network
|
|||
{
|
||||
Instances.Add(ns);
|
||||
ns.LogInfo("Connected. [{0} Online]", Instances.Count);
|
||||
ns.Start();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue