Patching to make compatible with appengine/socket.

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.
This commit is contained in:
Eric Gavaletz 2013-10-02 11:25:25 -04:00
parent 1e0d11ad8f
commit 7f3472cc74
1 changed files with 5 additions and 5 deletions

View File

@ -166,7 +166,7 @@ func (w *reply) read(p []byte) (n int, err error) {
switch w.client.Net {
case "tcp", "tcp4", "tcp6":
setTimeouts(w)
n, err = w.conn.(*net.TCPConn).Read(p[0:2])
n, err = w.conn.Read(p[0:2])
if err != nil || n != 2 {
return n, err
}
@ -177,13 +177,13 @@ func (w *reply) read(p []byte) (n int, err error) {
if int(l) > len(p) {
return int(l), io.ErrShortBuffer
}
n, err = w.conn.(*net.TCPConn).Read(p[:l])
n, err = w.conn.Read(p[:l])
if err != nil {
return n, err
}
i := n
for i < int(l) {
j, err := w.conn.(*net.TCPConn).Read(p[i:int(l)])
j, err := w.conn.Read(p[i:int(l)])
if err != nil {
return i, err
}
@ -192,7 +192,7 @@ func (w *reply) read(p []byte) (n int, err error) {
n = i
case "", "udp", "udp4", "udp6":
setTimeouts(w)
n, _, err = w.conn.(*net.UDPConn).ReadFromUDP(p)
n, err = w.conn.Read(p)
if err != nil {
return n, err
}
@ -251,7 +251,7 @@ func (w *reply) write(p []byte) (n int, err error) {
n = i
case "", "udp", "udp4", "udp6":
setTimeouts(w)
n, err = w.conn.(*net.UDPConn).Write(p)
n, err = w.conn.Write(p)
if err != nil {
return n, err
}