1.服务器端 Socket socketWatch = new Socket(AddressFamily.InterNetwork, SocketType.Stream,ProtocolType.Tcp); IPAddress ip; if (IPAddress.TryParse(txtIp.Text, out ip)) { try { IPEndPoint point = new IPEndPoint(ip, Convert.ToInt32(txtPort.Text)); socketWatch.Bind(point); ShowMsg("监听成功!