using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Net.Sockets; namespace Server { public class ClientHandler { TcpClient client; string name; bool keepRunning; public ClientHandler(TcpClient client, string name) { this.client = client; this.name = name; this.keepRunning = true; } public void stop() { keepRunning = false; } public void run() { Console.WriteLine("ClientHandler "+name+" started"); byte[] bytesFrom = new byte[10025]; //grootte overgenomen van voorbeeld string dataFromClient; while(keepRunning) { NetworkStream stream = client.GetStream(); stream.Read(bytesFrom,0, (int) client.ReceiveBufferSize); dataFromClient = System.Text.Encoding.ASCII.GetString(bytesFrom); dataFromClient = dataFromClient.Substring(0,dataFromClient.IndexOf('\n')); Console.WriteLine("ClientHandler "+name+" received: "+dataFromClient); } Console.WriteLine("ClientHandler "+name+" stopped"); } } }