
March 23rd, 2004, 09:44 AM
|
 |
DNS/BIND Guru
|
|
Join Date: Jun 2003
Location: OH, USA
|
|
You can use any source port for your UDP request. The only problem is if you have a simple firewall with no intelligence to let the DNS UDP responses through. Here's some of the code of my own resolver written in pure C (not C++):
In this example I don't even bind to a local port. I just let the system select one automatically since I have no firewall issues.
Code:
//create a socket for UDP
if (!(s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP)))
return 0;
//store the remote address info
sockaddr.sin_family = AF_INET;
sockaddr.sin_port = 0x3500; //port 53
memcpy(&sockaddr.sin_addr, &addr, 4);
//send the packet to the server
if (sendto(s, query, size+5, 0, (SOCKADDR*)&sockaddr, sizeof(SOCKADDR)) == SOCKET_ERROR) {
printf("Failed to send packet\n");
closesocket(s);
return 0;
}
__________________
Send me a private message if you would like me to setup your DNS for you for a price of your choosing. This is the preferred method if your DNS needs to be fixed/setup fast and you don't have the time to bounce messages back and forth on a forum. Also, check out these links:
Whois Direct | DNS Crawler | NS Trace | Compare Free DNS Hosts
|