reset a3, kut Charlie ;)
[tt2015.git] / a3 / code / clean-tcptest / Program.cs
1 using System;
2 using System.Collections.Generic;
3 using System.IO;
4 using System.Linq;
5 using System.Net.Sockets;
6 using System.Text;
7 using System.Threading.Tasks;
8
9 namespace TcpTest
10 {
11 class Program
12 {
13 static void Main(string[] args)
14 {
15 TcpListener tcp = new TcpListener(1203);
16 tcp.ExclusiveAddressUse = false;
17 tcp.Start();
18
19 while (true)
20 {
21 TcpClient client = tcp.AcceptTcpClient();
22 if (client == null)
23 {
24 continue;
25 }
26
27 Console.WriteLine("client connected...");
28 Stream stream = client.GetStream();
29
30 int ch = 0;
31 while ((ch=stream.ReadByte()) != -1)
32 {
33 Console.Write((char)ch);
34 }
35
36 client.Close();
37 client = null;
38 }
39 }
40 }
41 }