Merge pull request #81 from lovedboy/master
fix listenedAddr bug when TCP or UDP bind dynamic port
This commit is contained in:
commit
0a9db65df1
|
@ -223,18 +223,21 @@ func listen(tcp, utp bool, networkSuffix, addr string) (tcpL net.Listener, utpSo
|
|||
if tcp && utp && port == 0 {
|
||||
return listenBothSameDynamicPort(networkSuffix, host)
|
||||
}
|
||||
listenedAddr = addr
|
||||
if tcp {
|
||||
tcpL, err = listenTCP(networkSuffix, addr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
listenedAddr = tcpL.Addr().String()
|
||||
|
||||
}
|
||||
if utp {
|
||||
utpSock, err = listenUTP(networkSuffix, addr)
|
||||
if err != nil && tcp {
|
||||
tcpL.Close()
|
||||
return
|
||||
}
|
||||
listenedAddr = utpSock.Addr().String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue