/// <summary> /// Default constructor. /// </summary> /// <param name="responseLine">TcpMessage server response line.</param> /// <exception cref="ArgumentNullException">Is raised when <b>responseLine</b> is null.</exception> public TcpClientException(string responseLine) : base(responseLine.TrimEnd()) { if (responseLine == null) { throw new ArgumentNullException("responseLine"); } m_ReplyStream = TcpReplyStream.Parse(responseLine); }
/// <summary> /// Default constructor. /// </summary> /// <param name="replyStream">TcpMessage server error reply lines.</param> /// <exception cref="ArgumentNullException">Is raised when <b>replyLines</b> is null reference.</exception> public TcpClientException(TcpReplyStream replyStream) : base(replyStream.Text.TrimEnd()) { if (replyStream == null) { throw new ArgumentNullException("replyStream"); } m_ReplyStream = replyStream; }
/// <summary> /// Default constructor. /// </summary> /// <param name="message">Owner TcpMessage server message.</param> /// <param name="reply">TcpMessage server reply.</param> /// <exception cref="ArgumentNullException">Is raised when <b>message</b> or <b>reply</b> is null reference.</exception> public TcpStartedEventArgs(TcpMessage message, TcpReplyStream reply) { if (message == null) { throw new ArgumentNullException("message"); } if (reply == null) { throw new ArgumentNullException("reply"); } m_Task = message; m_Reply = reply; }
/// <summary> /// Default constructor. /// </summary> /// <param name="message">Owner TcpMessage server message.</param> /// <param name="stream">Message stream.</param> /// <param name="reply">TcpMessage server reply.</param> /// <exception cref="ArgumentNullException">Is raised when <b>message</b>, <b>stream</b> or <b>reply</b> is null reference.</exception> public TcpMessageCompletedEventArgs(TcpMessage message, Stream stream, TcpReplyStream reply) { if (message == null) { throw new ArgumentNullException("message"); } if (stream == null) { throw new ArgumentNullException("stream"); } if (reply == null) { throw new ArgumentNullException("reply"); } m_Task = message; m_Stream = stream; m_Reply = reply; }
/// <summary> /// Parses TcpMessage reply-stream /// </summary> /// <param name="stream">TcpMessage server reply-stream.</param> /// <returns>Returns parsed TcpMessage server reply-line.</returns> /// <exception cref="ArgumentNullException">Is raised when <b>line</b> is null reference.</exception> /// <exception cref="ParseException">Is raised when reply-line parsing fails.</exception> public static TcpReplyStream Parse(Stream stream) { if (stream == null) { throw new ArgumentNullException("stream"); } /* RFC 5321 4.2. * Reply-line = *( Reply-code "-" [ textstring ] CRLF ) * Reply-code [ SP textstring ] CRLF * * Since, in violation of this specification, the text is sometimes not sent, clients that do not * receive it SHOULD be prepared to process the code alone (with or without a trailing space character). */ TcpReplyStream reply = new TcpReplyStream(NetStream.EnsureNetStream(stream)); if (reply.ReplyCode <= 0) { throw new ParseException("Invalid TcpMessage server reply-stream '" + reply.ReplyCode.ToString() + "' reply-code."); } return(reply); }