public static SocketArgs GetSendArg() { var freeArg = SocketSendArgs.Find(x => x.IsInUse == false); if (freeArg == null) { var newArg = new SocketArgs(); newArg.IsInUse = true; SocketSendArgs.Add(newArg); return(newArg); } else { Array.Clear(freeArg.Buffer, 0, freeArg.Buffer.Length); freeArg.IsInUse = true; return(freeArg); } }
public static SocketArgs GetReceiveArg() { var freeArg = SocketReceiveArgs.Find(x => x.IsInUse == false); if (freeArg == null) { var newArg = new SocketArgs(); newArg.SetBuffer(new byte[Config.Current.BufferSize], 0, Config.Current.BufferSize); newArg.IsInUse = true; SocketReceiveArgs.Add(newArg); return(newArg); } else { freeArg.IsInUse = true; return(freeArg); } }