News  [SoftwareSite

Latest News
Older News
RSS Feed
 
Complete Projects
Useful Classes
Top Downloads
Message Board
AllAPI.net
 
Send Comments
Software License
Mentalis.org Buttons
Donate
 
Forums -> Miscellaneous Forum
 
DNS Resolve

Reply

by Keshav [keshavcn at yahoo dot com]
posted on 2005/08/19

I've trying to get MX records for a domain using c#. Below given code (taken from MSDN) works fine for me, when having direct internet connection:
------------------------------------------------------------------------------
IPHostEntry hostInfo = Dns.Resolve(hostString);
// Get the IP address list that resolves to the host names contained in the
// Alias property.
IPAddress[] address = hostInfo.AddressList;
// Get the alias names of the addresses in the IP address list.
String[] alias = hostInfo.Aliases;

Console.WriteLine("Host name : " + hostInfo.HostName);
Console.WriteLine("\nAliases : ");
for(int index=0; index < alias.Length; index++) {
Console.WriteLine(alias[index]);
}
Console.WriteLine("\nIP Address list :");
for(int index=0; index < address.Length; index++) {
Console.WriteLine(address[index]);
}
------------------------------------------------------------------------------
However, the same piece of code fails to work when I'm connecting to Internet through a Proxy Server and Socks5 authentication. Below mentioned error was received:
------------------------------------------------------------------------------
The requested name is valid, but no data of the requested type was found
------------------------------------------------------------------------------

Since C# Sockets doesn't support proxy, I'm using socket class provided by mentalis.org. I'm able to connect to the Proxy server but when trying to connect to a domain such as yahoo.com on port number 53 (default) I'm receiving "General SOCKS server failure.". I wonder what might be causing this error.

Org.Mentalis.Network.ProxySocket.ProxySocket s = new Org.Mentalis.Network.ProxySocket.ProxySocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
// set the proxy settings
s.ProxyEndPoint = new IPEndPoint(IPAddress.Parse("192.168.0.1"), 1080);
s.ProxyUser = "";
s.ProxyPass = "";
s.ProxyType = ProxyTypes.Socks5;
s.Connect("yahoo.com", 53);*** Immediately after this line I'm receiving this error.

If I try to connect to port number 80, then everything is working fine and I'm able to send & receive data.

Could anyone point out where I'm going wrong. Any help would be greatly appreciated. Thank You.

Keshav


PS:
If I try to make the socket UDP following error occured:

An existing connection was forcibly closed by the remote host

 

Copyright © 2002-2007, The Mentalis.org Team. All rights reserved.
This site is located at http://www.mentalis.org/
Send comments to the webmaster.