Expose the udp/tcp listening socket w/ ListenAndServe()

Expose the udp and tcp listening socket when ListenAndServe() is used, it seems like
plopping them on Server.Listener and Server.PacketConn would be ideal. The use case is so
that a port of zero can be used and having them exposed will allow for examination of the port
that is bound.
This commit is contained in:
Robert Gordon 2015-04-17 17:14:19 -05:00 committed by Miek Gieben
parent e98f4bc5ff
commit 5a357a6fc5
1 changed files with 2 additions and 0 deletions

View File

@ -264,6 +264,7 @@ func (srv *Server) ListenAndServe() error {
if e != nil {
return e
}
srv.Listener = l
return srv.serveTCP(l)
case "udp", "udp4", "udp6":
a, e := net.ResolveUDPAddr(srv.Net, addr)
@ -277,6 +278,7 @@ func (srv *Server) ListenAndServe() error {
if e := setUDPSocketOptions(l); e != nil {
return e
}
srv.PacketConn = l
return srv.serveUDP(l)
}
return &Error{err: "bad network"}