reset a3, kut Charlie ;)
[tt2015.git] / a3 / code / clean-tcptest / Program.cs
diff --git a/a3/code/clean-tcptest/Program.cs b/a3/code/clean-tcptest/Program.cs
new file mode 100644 (file)
index 0000000..7b20423
--- /dev/null
@@ -0,0 +1,41 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.IO;\r
+using System.Linq;\r
+using System.Net.Sockets;\r
+using System.Text;\r
+using System.Threading.Tasks;\r
+\r
+namespace TcpTest\r
+{\r
+    class Program\r
+    {\r
+        static void Main(string[] args)\r
+        {\r
+            TcpListener tcp = new TcpListener(1203);\r
+            tcp.ExclusiveAddressUse = false;\r
+            tcp.Start();\r
+\r
+            while (true)\r
+            {\r
+                TcpClient client = tcp.AcceptTcpClient();\r
+                if (client == null)\r
+                {\r
+                    continue;\r
+                }\r
+\r
+                Console.WriteLine("client connected...");\r
+                Stream stream = client.GetStream();\r
+\r
+                int ch = 0;\r
+                while ((ch=stream.ReadByte()) != -1)\r
+                {\r
+                    Console.Write((char)ch);\r
+                }\r
+\r
+                client.Close();\r
+                client = null;\r
+            }\r
+        }\r
+    }\r
+}\r