My First thread with TcpListener 
static void Main(string[] args)
{
TcpListener listener = new TcpListener(IPAddress.Any , 8000);
TcpClient client;
listener.Start();

while (true) // Add your exit flag here
{
client = listener.AcceptTcpClient();
ThreadPool.QueueUserWorkItem(ThreadProc, client);
}
}
private static void ThreadProc(object obj)
{
var client = (TcpClient)obj;
// Do your work here
}

[ 發表回應 ] ( 6預覽 )   |  常註連結  |   ( 3 / 250 )

| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 下一頁> >>