1
0
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:
Christopher Wedgwood 2010-05-24 16:53:23 -07:00 committed by Russ Cox
parent 751fc425ee
commit 5c19c4e5e3

View File

@ -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))
}