using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Net.Sockets; using System.Threading; using System.IO; namespace _2313_InClass_Server { public partial class Form1 : Form { TcpListener TC_Listener; Thread ListenerThread; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { TC_Listener = new TcpListener(2313); TC_Listener.Start(); ListenerThread = new Thread(new ThreadStart(ListenerWork)); ListenerThread.Start(); } private void ListenerWork() { while (true) { if (TC_Listener.Pending()) { TcpClient connection = TC_Listener.AcceptTcpClient(); textBoxLog.Text += ("Connection made: " + connection.Client.RemoteEndPoint.ToString() + "\r\n"); } } } } }