void receives()
{
TcpListener tcplisten = new TcpListener(new IPEndPoint(IPAddress.Any, 5000));
tcplisten.Start();
byte[] by = new byte[1024];
int ii;
while (true)
{
Socket s = tcplisten.AcceptSocket();
s.Receive(by);
string t = System.Text.Encoding.Default.GetString(by, 0, ii);
this.richTextBox1.AppendText(ip.ToString() + " 发来信息:" + t + "\r\n");
s.Close();
}
tcplisten.Stop();
}
试试这样吧