protected void InitSocket() { //if (Socket == null) //{ Socket = SocketHelper.GetSocket(ConnectType.TCP); //} }
public static T GetSocketEntity <T>(IPEndPoint ipEndPoint, ConnectType type) where T : SocketEntity, new() { Socket socket = SocketHelper.GetSocket(type); T entity = new T(); entity.Socket = socket; entity.IpEndPoint = ipEndPoint; return(entity); }
/// <summary> /// 获取数据后处理 /// </summary> /// <param name="buffer"></param> /// <param name="len"></param> /// <returns></returns> protected byte[] ParseData(byte[] data, int len) { try { //根据获取的数据的长度,重新创建一个byte[]保存实际数据 data = SocketHelper.GetSubArray(data, 0, len); if (Protocol != null) { data = Protocol.Parse(data, this); } } catch (Exception ex) { Log.error(ex); } return(data); }
public int SendMsg(string strMsg, object arg, AsyncCallback callback) { byte[] bytes = SocketHelper.GetBytesEx(strMsg, Encoding); return(SendMsg(bytes, arg, callback)); }
public override int SendMsg(string strMsg, object arg) { byte[] bytes = SocketHelper.GetBytesEx(strMsg, Encoding); return(SendMsg(bytes, arg)); }
protected void InitSocket() { this.Socket = SocketHelper.GetSocket(ConnectType.UDP); }