/// <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);
}
你先确定绑定的IP地址有效(ping...),然后尝试这个。https://www.cnblogs.com/maanshancss/p/11533062.html
IP用默认的就行 127.0.0.1