//监听UDP端口 public void startUDPListen(int port) { udptx = TxStart.startUdp(); udptx.Port = port; udptx.AcceptString += new TxDelegate <IPEndPoint, string>(UdpAcceptData); udptx.dateSuccess += new TxDelegate <IPEndPoint>(UdpDataSuccess); //接受成功数据回调 udptx.EngineClose += new TxDelegate(clientClose); //客户端引擎关闭 udptx.EngineLost += new TxDelegate <string>(clientLost); //客户端丢失连接 udptx.StartEngine(); }
/// <summary> /// UDP启动按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button6_Click(object sender, EventArgs e) { udptx = TxStart.startUdp(); udptx.Port = 13091;//如果要持续的进行监听,请在这里设置好非0的监听端口,一次性的话可以不用设置 udptx.AcceptString += new TxDelegate <IPEndPoint, string>(UdpAcceptString); udptx.dateSuccess += new TxDelegate <IPEndPoint>(UdpDateSuccess); udptx.EngineClose += new TxDelegate(engineClose); udptx.EngineLost += new TxDelegate <string>(engineLost); udptx.StartEngine(); button6.Enabled = false; }
/// <summary> /// UDP启动按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button6_Click(object sender, EventArgs e) { udptx = TxStart.startUdp(); udptx.Port = int.Parse(textBox1.Text); udptx.AcceptString += new TxDelegate <IPEndPoint, string>(UdpAcceptString); udptx.dateSuccess += new TxDelegate <IPEndPoint>(UdpDateSuccess); udptx.EngineClose += new TxDelegate(engineClose); udptx.EngineLost += new TxDelegate <string>(engineLost); udptx.StartEngine(); button6.Enabled = false; }