![](http://www.cee.hw.ac.uk/~ceesm6/Pics/StevesSig.gif)
Hi, i''m writing a mail program, and i need to do a DNS lookup for MX. I know DNS is UDP port 53, but is there a way to make it more reliable? At the moment it dies at recvfrom() sometimes, it just freezes. I''ve never used UDP before, and i''m using someone elses code. I''m guessing that it freezes because the data is never recieved (because UDP is unreliable).
Do i have to setup winsock to only wait for a short time (10 seconds or so) before re-sending the DNS request, or am i able to cheat somehow (is there an equivalent for gethostbyname() for MX records, or can i use TCP/IP)?
Thanks for any replies.
![](http://www.cee.hw.ac.uk/~ceesm6/Pics/StevesSig.gif)
Member of the Unban Mindwipe Society (UMWS)
gethostbyname() uses DNS too. If you want to get MX records you have to do it yourself.
UDP in fact is sometimes unreliable. but only a small number of the packets don''t recieve their destination (my experience).
use the setsockopt function to set a timeout, so if you don''t receive anything, "recvfrom" returns and you can try it again.
unsigned int nMillis = 5000; //try 5 seconds then return
setsockopt(sckSock, SOL_SOCKET, SO_RCVTIMEO, (char *) &nMillis, sizeof(nMillis))
by the way. here is a good dns (and others) tutorial: http://www.vijaymukhi.com/vmis/roll.htm.
it''s very interesting. try to program your own dns lookup. :-)
ciao
chris
UDP in fact is sometimes unreliable. but only a small number of the packets don''t recieve their destination (my experience).
use the setsockopt function to set a timeout, so if you don''t receive anything, "recvfrom" returns and you can try it again.
unsigned int nMillis = 5000; //try 5 seconds then return
setsockopt(sckSock, SOL_SOCKET, SO_RCVTIMEO, (char *) &nMillis, sizeof(nMillis))
by the way. here is a good dns (and others) tutorial: http://www.vijaymukhi.com/vmis/roll.htm.
it''s very interesting. try to program your own dns lookup. :-)
ciao
chris
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement