1,线程需要关闭
2,监听需要关闭
3,Socket需要关闭
4,如果是传文件的话还需要关闭流文件
黑色头发:http://heisetoufa.iteye.com
Thread TempThread;
//开启接收线程
TempThread = new Thread(new ThreadStart(this.StartReceive));
TempThread.IsBackground = true;//设置为后台线程
TempThread.Start();
TempThread.Abort();//关闭线程
2,监听需要关闭
TcpListener lisner;
//创建网络监听
lisner = new TcpListener(ipep);
lisner.Start();
lisner.Stop();
3,Socket需要关闭
Socket client = lisner.AcceptSocket();
//关闭套接字
client.Close();
4,如果是传文件的话还需要关闭流文件
FileStream MyFileStream = new FileStream(fileFullName, FileMode.Create, FileAccess.Write);
//关闭文件流
MyFileStream.Close();
黑色头发:http://heisetoufa.iteye.com