Commit 5df04180 authored by AlexStocks's avatar AlexStocks

close net.UDPConn when connected failed

parent 74b080a9
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
* nerr -> netError * nerr -> netError
* check udp connection alive after connect() * check udp connection alive after connect()
* use ReadFromUDP as the uniform UDP read interface * use ReadFromUDP as the uniform UDP read interface
* close net.UDPConn when connected failed
- 2018/03/17 - 2018/03/17
> improvement > improvement
* add end point type * add end point type
......
...@@ -169,6 +169,7 @@ func (c *client) dialUDP() Session { ...@@ -169,6 +169,7 @@ func (c *client) dialUDP() Session {
copy(buf, []byte(pingPacket)) copy(buf, []byte(pingPacket))
conn.SetWriteDeadline(wheel.Now().Add(1e9)) conn.SetWriteDeadline(wheel.Now().Add(1e9))
if length, err = conn.Write(buf[:len(pingPacket)]); err != nil { if length, err = conn.Write(buf[:len(pingPacket)]); err != nil {
conn.Close()
log.Warn("conn.Write(%s) = {length:%d, err:%s}", pingPacket, length, err) log.Warn("conn.Write(%s) = {length:%d, err:%s}", pingPacket, length, err)
time.Sleep(connInterval) time.Sleep(connInterval)
continue continue
...@@ -180,6 +181,7 @@ func (c *client) dialUDP() Session { ...@@ -180,6 +181,7 @@ func (c *client) dialUDP() Session {
} }
if err != nil { if err != nil {
log.Info("conn{%#v}.Read() = {length:%d, err:%s}", conn, length, err) log.Info("conn{%#v}.Read() = {length:%d, err:%s}", conn, length, err)
conn.Close()
time.Sleep(connInterval) time.Sleep(connInterval)
continue 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