1个回答
展开全部
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();
}
试试这样吧
{
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();
}
试试这样吧
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询