本帖最后由 nilaoyededie 于 2013-6-19 10:37 编辑
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void start_Click(object sender, EventArgs e)
{
Socket socketwatch = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPAddress address = IPAddress.Parse(IPBox.Text.Trim());
IPEndPoint engpoint = new IPEndPoint(address, int.Parse(reBox.Text));
socketwatch.Bind(engpoint);
socketwatch.Listen(10);
Socket socConnetion = socketwatch.Accept();
Message("客户端连接成功");
}
void Message(string msg)
{
Boxmes.AppendText(msg + "\r\n");
}
}
|
|