Ticket #5240: tcpserver.cs

File tcpserver.cs, 553 bytes (added by andreasf, 15 years ago)

test server

Line 
1// Copyright (c) 2010 Andreas Faerber <andreas.faerber@web.de>
2// All rights reserved. Distributed under the terms of the MIT License.
3
4using System;
5using System.Net;
6using System.Net.Sockets;
7
8class Test {
9 static void Main() {
10 TcpListener listener = new TcpListener(IPAddress.Any, 8888);
11 listener.Start();
12 while (true) {
13 Console.Write("Listening...");
14 TcpClient client = listener.AcceptTcpClient();
15 Console.Write("connected to {0}, closing...", client.Client.RemoteEndPoint);
16 client.Close();
17 Console.WriteLine("done.");
18 }
19 }
20}