Commit 5df04180 authored by AlexStocks's avatar AlexStocks

close net.UDPConn when connected failed

parent 74b080a9
......@@ -19,7 +19,8 @@
* nerr -> netError
* check udp connection alive after connect()
* use ReadFromUDP as the uniform UDP read interface
* close net.UDPConn when connected failed
- 2018/03/17
> improvement
* add end point type
......
......@@ -169,6 +169,7 @@ func (c *client) dialUDP() Session {
copy(buf, []byte(pingPacket))
conn.SetWriteDeadline(wheel.Now().Add(1e9))
if length, err = conn.Write(buf[:len(pingPacket)]); err != nil {
conn.Close()
log.Warn("conn.Write(%s) = {length:%d, err:%s}", pingPacket, length, err)
time.Sleep(connInterval)
continue
......@@ -180,6 +181,7 @@ func (c *client) dialUDP() Session {
}
if err != nil {
log.Info("conn{%#v}.Read() = {length:%d, err:%s}", conn, length, err)
conn.Close()
time.Sleep(connInterval)
continue
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment