扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
using System.IO; using System.Net.Sockets; Pop3Connection类的成员变量包括以下几个: private TcpClient socket; private StreamReader reader; private StreamWriter writer; private bool connected; |
public bool Connected { get{return connected;} } Pop3Connection类的主要方法包含以下几个: internal void Open(string host, int port) { if(host == null || host.Trim().Length == 0 || port <= 0) { throw new System.ArgumentException("Invalid Argument found."); } socket.Connect(host, port); reader = new StreamReader(socket.GetStream(), System.Text.Encoding.ASCII); writer = new StreamWriter(socket.GetStream(), System.Text.Encoding.ASCII); connected = true; } internal void SendCommand(string cmd) { writer.WriteLine(cmd); writer.Flush(); } internal void GetReply(out string reply, out int code) { reply = reader.ReadLine(); code = reply == null ? -1 : Int32.Parse(reply.Substring(0, 3)); } internal void Close() { reader.Close(); writer.Flush(); writer.Close(); reader = null; writer = null; socket.Close(); connected = false; } |
/// /// 主机名 /// public string Host { get {return host;} set { if(value == null || value.Trim().Length == 0) { throw new ArgumentException("Invalid host name."); } host = value; } } /// /// 端口号 /// public int Port { get {return port;} set { if(value <= 0) { throw new ArgumentException("Invalid port."); } port = value; } } /// /// 用户名 /// public string UserName { get {return username;} set { if(value == null || value.Trim().Length == 0) { throw new ArgumentException("Invalid user name."); } username = value; } } /// /// 密码 /// public string PassWord { get {return password;} set { if(value == null) { throw new ArgumentException("Invalid password."); } password = value; } } /// /// 邮件数量 /// public int NumOfMails { get {return numofmails;} } /// /// 邮件总体积 /// public double TotalSize { get {return totalsize;} } /// /// 邮件内容 /// public string Body { get {return body;} } /// /// 状态信息 /// public string Status { get {return status;} } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者