Mercurial > hg > Database > Christie-sharp
view 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 source
using System; using System.Net; using System.Net.Sockets; using System.Threading.Tasks; using Christie_net.codegear; namespace Christie_net.daemon { public class AcceptThread { private Socket soc; public int counter = 0; public CodeGearManager cgm; public AcceptThread(Socket soc, CodeGearManager cgm) { this.soc = soc; this.cgm = cgm; } public void Run() { while (true) { try { 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.Factory.StartNew( () => incoming.Run(), TaskCreationOptions.LongRunning); //cgm.SetAccept(key, in); OutboundTcpConnection outbound = new OutboundTcpConnection(connection); Task.Factory.StartNew( () => outbound.Run(), TaskCreationOptions.LongRunning); counter++; } catch (Exception e) { Console.WriteLine(e.StackTrace); } } } } }