FTPReply?ReadNextReply() { if (CachedReply.Count > 0) { return(CachedReply.Dequeue()); } string streamstring = null; try { streamstring = MyFTPHelper.ReadFromNetStream(controlStream); } catch (Exception exc) { throw exc; } string[] messages = streamstring.Split(new string[] { MyFTPHelper.FTPNewLine }, StringSplitOptions.RemoveEmptyEntries); Array.ForEach(messages, (m) => CachedReply.Enqueue(FTPReply.String2Reply(m))); if (CachedReply.Count > 0) { return(CachedReply.Dequeue()); } else { return(null); } }
public static FTPCommand?ReadNextCommand(NetworkStream stream) { if (CachedCommands.Count > 0) { return(CachedCommands.Dequeue()); } string streamstring = null; try { streamstring = MyFTPHelper.ReadFromNetStream(stream); } catch (Exception exc) { throw exc; } string[] messages = streamstring.Split(new string[] { MyFTPHelper.FTPNewLine }, StringSplitOptions.RemoveEmptyEntries); Array.ForEach(messages, (m) => CachedCommands.Enqueue(FTPCommand.String2Command(m))); if (CachedCommands.Count > 0) { return(CachedCommands.Dequeue()); } else { return(null); } }