private void InitUdp(int port = 8893) { try { SocketMessageMng socket = new SocketMessageMng(port); socket.UdpStartListen(); socket.SetTextEvent += Socket_SetTextEvent; } catch (Exception ex) { Console.WriteLine("Udp异常:{0}", ex.ToString()); } }
/// <summary> /// 实例化转化发消息 /// </summary> /// <param name="port"></param> public virtual void InitUdp(int port, string desc) { try { socket = new SocketMessageMng(port); socket.UdpStartListen(); socket.SetTextEvent += Socket_SetTextEvent; logger.Info("Udp初始化成功:{0}" + (string.IsNullOrEmpty(desc) ? string.Empty : "," + desc), port); } catch (Exception ex) { logger.Error("Udp异常:{0}", ex.ToString()); } }
public IHttpActionResult UDPSendMsg(string strIP, int nPort, string strMsg) { try { SocketMessageMng sm = new SocketMessageMng(); sm.UdpSendMsg(strIP, nPort, strMsg); sm.Dis(); return(Ok(new { status = 1, data = true })); } catch (Exception ex) { return(Ok(new { status = 1, data = false })); } }
private MessageComm() { smSend = new SocketMessageMng(); }