满意答案
hgys6d5jdl0
2013.04.11
采纳率:44% 等级:11
已帮助:7706人
很久以前写过一个c#版的鸽子,在这共享一点代码,不知道是不是你想要的,该改的自己改改
private void button1_Click(object sender, System.EventArgs e)
{
th=new Thread(new ThreadStart(this.listen));
th1=new Thread(new ThreadStart(this.send));
th.Start();
}
public void listen()
{
try
{
IPAddress ip=IPAddress.Parse(this.comboBox1.Text.Trim());
tl=new TcpListener(ip,int.Parse(this.txtport.Text.Trim()));
tl.Start();
s=tl.AcceptSocket();
while(s.Connected){th.Abort();th1.Start();}
}
catch{}
}
public void send()
{
try
{
s.Send(System.Text.Encoding.Unicode.GetBytes(this.txtsend.Text));
}catch{}
}
00分享举报