public Write ( byte buffer, int offset, int count ) : void | ||
buffer | byte | The buffer to write. |
offset | int | The offset of the first byte to write. |
count | int | The number of bytes to write. |
return | void |
async Task SendCommandAsync(Pop3Command pc, bool doAsync, CancellationToken cancellationToken) { var buf = pc.Encoding.GetBytes(pc.Command + "\r\n"); if (doAsync) { await stream.WriteAsync(buf, 0, buf.Length, cancellationToken).ConfigureAwait(false); } else { stream.Write(buf, 0, buf.Length, cancellationToken); } }
void ProcessCommand(Pop3Command pc) { string response, text; byte[] buf; buf = Encoding.UTF8.GetBytes(pc.Command + "\r\n"); stream.Write(buf, 0, buf.Length); try { response = ReadLine(pc.CancellationToken).TrimEnd(); } catch { pc.Status = Pop3CommandStatus.ProtocolError; Disconnect(); throw; } pc.Status = GetCommandStatus(response, out text); switch (pc.Status) { case Pop3CommandStatus.ProtocolError: Disconnect(); throw new Pop3ProtocolException(string.Format("Unexpected response from server: {0}", response)); case Pop3CommandStatus.Continue: case Pop3CommandStatus.Ok: if (pc.Handler != null) { try { pc.Handler(this, pc, text); } catch { pc.Status = Pop3CommandStatus.ProtocolError; Disconnect(); throw; } } break; } }
void SendCommand(Pop3Command pc) { var buf = Encoding.UTF8.GetBytes(pc.Command + "\r\n"); stream.Write(buf, 0, buf.Length); }