System.Net.Sockets.SocketException
Encoding en = Encoding.GetEncoding("iso-8859-1"); // default encoding
IPHostEntry IPhst = Dns.GetHostEntry(_Host);
IPEndPoint endPt = new IPEndPoint(IPhst.AddressList[0], 25);
Socket s = new Socket(endPt.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
s.Connect(endPt);
这里收到如下错误:
System.Net.Sockets.SocketException:连接尝试失败,因为连接方在一段时间后没有正确响应,或者由于连接的主机未能响应而建立的连接失败202.88.253.162:25 在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)"
我该如何解决这个问题?
Encoding en = Encoding.GetEncoding("iso-8859-1"); // default encoding
IPHostEntry IPhst = Dns.GetHostEntry(_Host);
IPEndPoint endPt = new IPEndPoint(IPhst.AddressList[0], 25);
Socket s = new Socket(endPt.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
s.Connect(endPt);
Here am getting the error like:
System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 202.88.253.162:25
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)"
How i can solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有服务器在侦听您尝试连接的指定 IP/端口。
错误的可能原因:
更新
没有看到您正在尝试连接到 SMTP 服务器。许多 ISP 会阻止除其自己的 SMTP 服务器之外的所有 IP 地址的端口 25。这是为了减少垃圾邮件。所以这也可能是原因。
The is no server listening at specified ip/port that you are trying to connect to.
Possible causes for the error:
Update
Didn't see that you are trying to connect to a SMTP server. Many ISP:s block port 25 for all ip addresses except their own SMTP servers. It's to reduce SPAM emails. So that could be the cause too.
尝试使用 IP 127.0.0.1 。它可能会起作用。
Try using the IP 127.0.0.1 . It might work.