

/// <summary>
/// 启动
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void butStart_Click(object sender, EventArgs e)
{
//1、创建Socket对象
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
//2、绑定端口IP
socket.Bind(new IPEndPoint(IPAddress.Parse(txtIP.Text), int.Parse(txtPort.Text)));
//3、开启侦听
socket.Listen(10); //连接等待队列
//4、开始接受客户端的连接
ThreadPool.QueueUserWorkItem(new WaitCallback (this.AcceptClientConnect),socket);
}