mirror of
https://github.com/huin/goupnp.git
synced 2025-09-26 20:31:10 +08:00
Add support to httpuClient for specific port
This commit is contained in:

committed by
John Beisley

parent
538e53587e
commit
5a65ac4683
@@ -69,13 +69,20 @@ func NewHTTPUClient() (*HTTPUClient, error) {
|
||||
}
|
||||
|
||||
// NewHTTPUClientAddr creates a new HTTPUClient which will broadcast packets
|
||||
// from the specified address, opening up a new UDP socket for the purpose
|
||||
// from the specified address, opening up a new UDP socket for the purpose on a random port
|
||||
func NewHTTPUClientAddr(addr string) (*HTTPUClient, error) {
|
||||
ip := net.ParseIP(addr)
|
||||
if ip == nil {
|
||||
return nil, errors.New("Invalid listening address")
|
||||
}
|
||||
conn, err := net.ListenPacket("udp", ip.String()+":0")
|
||||
|
||||
return NewHTTPUClientAddrWithPort(ip.String() + ":0")
|
||||
}
|
||||
|
||||
// NewHTTPUClientAddrWithPort creates a new HTTPUClient which will broadcast packets
|
||||
// from the specified address, opening up a new UDP socket for the purpose on a specific port
|
||||
func NewHTTPUClientAddrWithPort(addr string) (*HTTPUClient, error) {
|
||||
conn, err := net.ListenPacket("udp", addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user