'''' The class of query (1 means INET) iTemp = htons(1) MemCopy dnsQuery(dnsQueryNdx), iTemp, Len(iTemp) dnsQueryNdx = dnsQueryNdx + Len(iTemp)
On Error Resume Next ReDim Preserve dnsQuery(dnsQueryNdx - 1) '''' Send the query to the DNS server objWinSock.RemoteHost = DNS_Addr DNSrecieved = False objWinSock.SendData dnsQuery
If WaitUntilTrue(DNSrecieved, 60) = False Then ''''MX_Query = "" Exit Function End If
Dim iAnCount As Integer '''' Get the number of answers MemCopy iAnCount, dnsReply(6), 2 iAnCount = ntohs(iAnCount) '''' Parse the answer buffer MX_Query = Trim(GetMXName(dnsReply(), 12, iAnCount))
End Function
Private Function WaitUntilTrue(ByRef Flag As Boolean, ByVal SecondsToWait As Long) As Boolean
Dim fStart As Single Dim fTimetoQuit As Single
fStart = Timer
'''' Deal with timer being reset at Midnight If fStart + SecondsToWait < 86400 Then fTimetoQuit = fStart + SecondsToWait Else fTimetoQuit = (fStart - 86400) + SecondsToWait End If
Do Until Flag = True If Timer >= fTimetoQuit Then WaitUntilTrue = Flag Exit Function End If DoEvents Sleep (10) Loop