diff options
author | Christopher Wedgwood <cw@f00f.org> | 2010-05-24 16:53:23 -0700 |
---|---|---|
committer | Christopher Wedgwood <cw@f00f.org> | 2010-05-24 16:53:23 -0700 |
commit | efe2fcc938b0b1a852117e3c2ffb0aa130e6a514 (patch) | |
tree | 8a879ab6fdc34517a9269eaeb7f5b4174a763a27 /src/pkg/net | |
parent | 04d6d9dcf8361cb3c64130930cd75bf57773e306 (diff) | |
download | golang-efe2fcc938b0b1a852117e3c2ffb0aa130e6a514.tar.gz |
net: udp, implement BindToDevice
R=rsc
CC=golang-dev, r
http://codereview.appspot.com/1271041
Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/pkg/net')
-rw-r--r-- | src/pkg/net/udpsock.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/pkg/net/udpsock.go b/src/pkg/net/udpsock.go index 6de69a9c9..5e22c778d 100644 --- a/src/pkg/net/udpsock.go +++ b/src/pkg/net/udpsock.go @@ -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)) +} |