使用 POP3 的 TcpClient 响应流,无法读取超过一行
我正在为 pop3 开发自己的库,因为我没有在此处建议的库中找到我需要的东西。我的问题是,当打开一条消息时,它只能读取一行到某个点(通常是文本中的链接),然后它会停止,循环但不会崩溃。代码是:
Data = "RETR 1" + CRLF;
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
NetStrm.Write(szData, 0, szData.Length);
txtLog.Text += RdStrm.ReadLine() + CRLF;
for (int i = 0; i < 33; i++)
{
txtLog.Text += RdStrm.ReadLine() + CRLF;
}
string szTemp;
szTemp = RdStrm.ReadLine();
// here it's supposed to start reading the actual message
while(szTemp != "-")
{
txtLog.Text += szTemp + CRLF;
szTemp = RdStrm.ReadLine();
}
I am working on my own lib for pop3 since i didnt find what I needed in the ones that were suggested here. My problem is when opening a message it can only read a line up to a certain point (usually a link in the text) and it stops, looping but not crashing. code is:
Data = "RETR 1" + CRLF;
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
NetStrm.Write(szData, 0, szData.Length);
txtLog.Text += RdStrm.ReadLine() + CRLF;
for (int i = 0; i < 33; i++)
{
txtLog.Text += RdStrm.ReadLine() + CRLF;
}
string szTemp;
szTemp = RdStrm.ReadLine();
// here it's supposed to start reading the actual message
while(szTemp != "-")
{
txtLog.Text += szTemp + CRLF;
szTemp = RdStrm.ReadLine();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就解决了,看起来互联网需要一个好的、开源的、易于修改的库,所以这就是我接下来要做的。谢谢大家。现在完美运行
that settles it, looks like the internet is in a need for a good, open source, easy to modify lib, so that's what i'll do next. Thanks everyone. Works perfectly now
如果另一端的服务返回以 CRLF 结尾的行,那么从 Readline 获取的行末尾将有一个 CR。
所以返回的字符串将始终是 != "-"。
If the service at the other end returns lines that end with CRLF, then the lines you get from Readline will have a CR at the end.
So the returned string will always be != "-".