// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using System.IO; using System.Net; using System.Net.Sockets; public class NServer { public static void Main(string[] args) { TcpListener srv = new TcpListener(IPAddress.Any, 1234); srv.Start(); using(TcpClient cli = srv.AcceptTcpClient()) { using(StreamReader sr = new StreamReader(cli.GetStream())) { for(int i = 0; i < 10000000; i++) { if(sr.ReadLine() != "Dette er en test") { throw new Exception("Ooops"); } } } } } }