开发者

A socket operation was attempted to an unreachable network

I am trying to validate email domain validation using the following code (Found on Code Proejct)

string hostName="<hostName>"; //Ex: yahoo.com
IPHostEntry Iphost=D开发者_C百科ns.GetHostEntry(hostName);
IPEndPoint endPt=new IPEndPoint(Iphost.AddressList[0],25);
Socket s=new Socket(endPt.AdressFamily, SocketType.Stream, ProtocolType.Tcp);

s.Connect(endPt);

At s.Connect I am getting the error: A socket operation was attempted to an unreachable network. What might be the possible reasons and how can I resolve them? I have Firewall (Comodo) on my machine.


The computer is not able to connect to the address that was resolved.

Look at the address you were given by Dns.Resolve.

Note: The Resolve method is obsolete, and replaced with GetHostEntry. e.g.:

IPHostEntry host = Dns.GetHostEntry("yahoo.com");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜