Mercurial > hg > Database > Christie-sharp
diff daemon/AcceptThread.cs @ 26:45ff08d59fda
update CGM
author | riono <e165729@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 12 Jan 2021 21:23:23 +0900 |
parents | 52cb63c37218 |
children | 0cd2684e401b |
line wrap: on
line diff
--- a/daemon/AcceptThread.cs Fri Dec 18 01:06:47 2020 +0900 +++ b/daemon/AcceptThread.cs Tue Jan 12 21:23:23 2021 +0900 @@ -18,20 +18,24 @@ public void Run() { while (true) { try { - Socket socket = soc; - socket.Listen((int)SocketOptionName.MaxConnections); + Socket socket = null; + socket = soc.Accept(); socket.NoDelay = true; Console.WriteLine("Accept " + socket.LocalEndPoint + ":" + ((IPEndPoint)socket.LocalEndPoint).Port); Connection connection = new Connection(socket, cgm); string key = "accept" + counter; - IncomingTcpConnection inComing = new IncomingTcpConnection(connection); - Task.Run(() => inComing.Run()); + IncomingTcpConnection incoming = new IncomingTcpConnection(connection); + Task.Factory.StartNew( + () => incoming.Run(), + TaskCreationOptions.LongRunning); //cgm.SetAccept(key, in); - OutboundTcpConnection outBound = new OutboundTcpConnection(connection); - Task.Run(() => outBound.Run()); + OutboundTcpConnection outbound = new OutboundTcpConnection(connection); + Task.Factory.StartNew( + () => outbound.Run(), + TaskCreationOptions.LongRunning); counter++; } catch (Exception e) { Console.WriteLine(e.StackTrace);