mirror of
https://github.com/golang/go
synced 2024-11-20 04:04:41 -07:00
net: udp, implement BindToDevice
R=rsc CC=golang-dev, r https://golang.org/cl/1271041
This commit is contained in:
parent
751fc425ee
commit
5c19c4e5e3
@ -259,3 +259,13 @@ func ListenUDP(net string, laddr *UDPAddr) (c *UDPConn, err os.Error) {
|
||||
}
|
||||
return newUDPConn(fd), nil
|
||||
}
|
||||
|
||||
// BindToDevice binds a UDPConn to a network interface.
|
||||
func (c *UDPConn) BindToDevice(device string) os.Error {
|
||||
if !c.ok() {
|
||||
return os.EINVAL
|
||||
}
|
||||
c.fd.incref()
|
||||
defer c.fd.decref()
|
||||
return os.NewSyscallError("setsockopt", syscall.BindToDevice(c.fd.sysfd, device))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user