The interface conversion from socket.Conn to net.UDPConn fails, but
since you can use a generic Read(b) in place of ReadFromUDP(b) it makes
sense to git rid of the conversion to net.UDPConn. This change allows
the use of the client library for UDP DNS lookup using the
appengine/socket package's Conn.
For the same reasons the interface conversions for TCP connections were
also removed.
Export lowlevel function and types so that they may be used.
They higher level Exchange function is still there. ExchangeConn
is gone, because it is not needed.
Didn't like it anyway and it made the calling logic a mess. So it is
now removed. Failed queries can be redone, but they should be initiated
from the client, not within the library.
Thanks to a bug report from Vitalie Cherpec which commented that this
didn't work.
The timeout settings we not in the client.attempts loop, so they
were only active for the first attempt. And the loop wasn't broken
out of when the write or read succeeded.
Both these issues are now fixed.
Before the tcp writes were done like NSD does them:
2 bytes length, and the rest of the message.
Now a complete buffer is created with LLMMM...MMM, where
LL is the 2 byte length and MMM...MMM is the message to be send.
This makes the reply faster at the cost of doing a realloc of the
message buffer.
All the relevant functions now return an error instead of
a simple boolean. This greatly approves the feedback to coders.
Spotted some fishy error handling along the way and fix that too.