----------------------
Windows Phone 7手机开发、
.Net培训、期待与您交流! ----------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace 网络聊天
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//关闭微软 控件跨线程检查
TextBox.CheckForIllegalCrossThreadCalls = false;
}
//将用于 监听有没有客户端连接请求的套接字 设置为全局变量,那么在WatchClientConnection方法里也可以直接访问
Socket socketWatch = null;
//存放每一个 客户端的 套接字的字典集
Dictionary<string, Socket> dictSocket = new Dictionary<string, Socket>();
//存放和 每一个 客户端 通讯的 单独的线程 的字典集
Dictionary<string, Thread> dictThread = new Dictionary<string, Thread>();
/// <summary>
/// 创建循环监听有没有客户端连接的套接字, 开启监听
/// </summary>
/// <param name="sender