public void Test() { udp = new AsyncUDP(1313, true, true, __INIT); udp.OnLog += new AsyncUDP.LogHandler(LogHandler); udp.OnCommand += new AsyncUDP.CommandHandler(KeyHandler); udp.Start(); }
private void txtSendMsg_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode != Keys.Enter) { return; } string[] arr = txtSendTo.Text.Split(':'); byte[] buf = null; if (chkHexString.Checked) { buf = txtSendMsg.Text.ToByteArray(); } else { buf = Encoding.Default.GetBytes(txtSendMsg.Text); } if (chkBroadcast.Checked) { AsyncUDP.Broadcast(Convert.ToInt32(arr[1]), buf); } else { _Server.SendData(new IPEndPoint(IPAddress.Parse(arr[0]), Convert.ToInt32(arr[1])), buf); } txtSendMsg.SelectAll(); }
public FAsyncUdpServer() { InitializeComponent(); _Server = new AsyncUDP(Convert.ToInt32(txtBuffer.Text)); _Server.DataReceived += new EventHandler <AsyncUdpEventArgs>(Server_OnDataReceived); _Server.MonitorStarted += new EventHandler <AsyncUdpEventArgs>(Server_OnStarted); _Server.MonitorStoped += new EventHandler <AsyncUdpEventArgs>(Server_OnShutdown); _Server.Exception += new EventHandler <AsyncUdpEventArgs>(Server_OnException); foreach (IPAddress ipa in TcpManager.GetHostIP()) { cboIP.Items.Add(ipa.ToString()); } }
void Start() { udp = new AsyncUDP (LISTENING_PORT, BROADCAST_PORT); udp.Start (); }