Mercurial > hg > Database > Christie-sharp
changeset 65:058d41dcec41
fix AcceptThread loop
author | riono <e165729@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 29 Jan 2022 20:28:13 +0900 |
parents | 83e02a762168 |
children | 312de6b900bc |
files | Christie_net.csproj daemon/AcceptThread.cs |
diffstat | 2 files changed, 22 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/Christie_net.csproj Sat Jan 29 17:57:33 2022 +0900 +++ b/Christie_net.csproj Sat Jan 29 20:28:13 2022 +0900 @@ -3,7 +3,7 @@ <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp6.0</TargetFramework> - <StartupObject>Christie_net.Test.Topology.TreeTestTopology.StartTreeTestTopology</StartupObject> + <StartupObject>Christie_net.Test.Example.FizzBuzz.StartFizzBuzz</StartupObject> </PropertyGroup> <ItemGroup>
--- a/daemon/AcceptThread.cs Sat Jan 29 17:57:33 2022 +0900 +++ b/daemon/AcceptThread.cs Sat Jan 29 20:28:13 2022 +0900 @@ -17,30 +17,32 @@ } public void Run() { - try { - TcpClient client = null; - client = listener.AcceptTcpClient(); - client.NoDelay = true; + while (true) { + try { + TcpClient client = null; + client = listener.AcceptTcpClient(); + client.NoDelay = true; - IPEndPoint endPoint = (IPEndPoint) client.Client.RemoteEndPoint; - IPAddress ipAddress = endPoint.Address; - IPHostEntry hostEntry = Dns.GetHostEntry(ipAddress); - Console.WriteLine("Accept " + hostEntry.HostName + ":" + endPoint.Port); + IPEndPoint endPoint = (IPEndPoint) client.Client.RemoteEndPoint; + IPAddress ipAddress = endPoint.Address; + IPHostEntry hostEntry = Dns.GetHostEntry(ipAddress); + Console.WriteLine("Accept " + hostEntry.HostName + ":" + endPoint.Port); - Connection connection = new Connection(client.Client, cgm); - Console.WriteLine("connection:" + connection.GetInfoString()); - string key = "accept" + counter; + Connection connection = new Connection(client.Client, cgm); + Console.WriteLine("connection:" + connection.GetInfoString()); + string key = "accept" + counter; - IncomingTcpConnection incoming = new IncomingTcpConnection(connection); - Task.Factory.StartNew(() => incoming.Run()); + IncomingTcpConnection incoming = new IncomingTcpConnection(connection); + Task.Factory.StartNew(() => incoming.Run()); - cgm.SetAccept(key, incoming); + cgm.SetAccept(key, incoming); - OutboundTcpConnection outbound = new OutboundTcpConnection(connection); - Task.Factory.StartNew(() => outbound.Run()); - counter++; - } catch (Exception e) { - Console.WriteLine(e.StackTrace); + OutboundTcpConnection outbound = new OutboundTcpConnection(connection); + Task.Factory.StartNew(() => outbound.Run()); + counter++; + } catch (Exception e) { + Console.WriteLine(e.StackTrace); + } } } }