summaryrefslogtreecommitdiff
path: root/src/pkg/net/udpsock_plan9.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/net/udpsock_plan9.go')
-rw-r--r--src/pkg/net/udpsock_plan9.go75
1 files changed, 42 insertions, 33 deletions
diff --git a/src/pkg/net/udpsock_plan9.go b/src/pkg/net/udpsock_plan9.go
index bb7196041..4f298a42f 100644
--- a/src/pkg/net/udpsock_plan9.go
+++ b/src/pkg/net/udpsock_plan9.go
@@ -7,7 +7,10 @@
package net
import (
+ "errors"
"os"
+ "syscall"
+ "time"
)
// UDPConn is the implementation of the Conn and PacketConn
@@ -16,6 +19,21 @@ type UDPConn struct {
plan9Conn
}
+// SetDeadline implements the Conn SetDeadline method.
+func (c *UDPConn) SetDeadline(t time.Time) error {
+ return syscall.EPLAN9
+}
+
+// SetReadDeadline implements the Conn SetReadDeadline method.
+func (c *UDPConn) SetReadDeadline(t time.Time) error {
+ return syscall.EPLAN9
+}
+
+// SetWriteDeadline implements the Conn SetWriteDeadline method.
+func (c *UDPConn) SetWriteDeadline(t time.Time) error {
+ return syscall.EPLAN9
+}
+
// UDP-specific methods.
// ReadFromUDP reads a UDP packet from c, copying the payload into b.
@@ -23,10 +41,10 @@ type UDPConn struct {
// that was on the packet.
//
// ReadFromUDP can be made to time out and return an error with Timeout() == true
-// after a fixed time limit; see SetTimeout and SetReadTimeout.
-func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err os.Error) {
+// after a fixed time limit; see SetDeadline and SetReadDeadline.
+func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err error) {
if !c.ok() {
- return 0, nil, os.EINVAL
+ return 0, nil, syscall.EINVAL
}
if c.data == nil {
c.data, err = os.OpenFile(c.dir+"/data", os.O_RDWR, 0)
@@ -40,7 +58,7 @@ func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err os.Error) {
return
}
if m < udpHeaderSize {
- return 0, nil, os.NewError("short read reading UDP header")
+ return 0, nil, errors.New("short read reading UDP header")
}
buf = buf[:m]
@@ -49,10 +67,10 @@ func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err os.Error) {
return n, &UDPAddr{h.raddr, int(h.rport)}, nil
}
-// ReadFrom implements the net.PacketConn ReadFrom method.
-func (c *UDPConn) ReadFrom(b []byte) (n int, addr Addr, err os.Error) {
+// ReadFrom implements the PacketConn ReadFrom method.
+func (c *UDPConn) ReadFrom(b []byte) (n int, addr Addr, err error) {
if !c.ok() {
- return 0, nil, os.EINVAL
+ return 0, nil, syscall.EINVAL
}
return c.ReadFromUDP(b)
}
@@ -61,11 +79,11 @@ func (c *UDPConn) ReadFrom(b []byte) (n int, addr Addr, err os.Error) {
//
// WriteToUDP can be made to time out and return
// an error with Timeout() == true after a fixed time limit;
-// see SetTimeout and SetWriteTimeout.
+// see SetDeadline and SetWriteDeadline.
// On packet-oriented connections, write timeouts are rare.
-func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (n int, err os.Error) {
+func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (n int, err error) {
if !c.ok() {
- return 0, os.EINVAL
+ return 0, syscall.EINVAL
}
if c.data == nil {
c.data, err = os.OpenFile(c.dir+"/data", os.O_RDWR, 0)
@@ -86,14 +104,14 @@ func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (n int, err os.Error) {
return c.data.Write(buf)
}
-// WriteTo implements the net.PacketConn WriteTo method.
-func (c *UDPConn) WriteTo(b []byte, addr Addr) (n int, err os.Error) {
+// WriteTo implements the PacketConn WriteTo method.
+func (c *UDPConn) WriteTo(b []byte, addr Addr) (n int, err error) {
if !c.ok() {
- return 0, os.EINVAL
+ return 0, syscall.EINVAL
}
a, ok := addr.(*UDPAddr)
if !ok {
- return 0, &OpError{"writeto", "udp", addr, os.EINVAL}
+ return 0, &OpError{"write", c.dir, addr, syscall.EINVAL}
}
return c.WriteToUDP(b, a)
}
@@ -101,14 +119,14 @@ func (c *UDPConn) WriteTo(b []byte, addr Addr) (n int, err os.Error) {
// DialUDP connects to the remote address raddr on the network net,
// which must be "udp", "udp4", or "udp6". If laddr is not nil, it is used
// as the local address for the connection.
-func DialUDP(net string, laddr, raddr *UDPAddr) (c *UDPConn, err os.Error) {
+func DialUDP(net string, laddr, raddr *UDPAddr) (c *UDPConn, err error) {
switch net {
case "udp", "udp4", "udp6":
default:
return nil, UnknownNetworkError(net)
}
if raddr == nil {
- return nil, &OpError{"dial", "udp", nil, errMissingAddress}
+ return nil, &OpError{"dial", net, nil, errMissingAddress}
}
c1, err := dialPlan9(net, laddr, raddr)
if err != nil {
@@ -149,14 +167,14 @@ func unmarshalUDPHeader(b []byte) (*udpHeader, []byte) {
// local address laddr. The returned connection c's ReadFrom
// and WriteTo methods can be used to receive and send UDP
// packets with per-packet addressing.
-func ListenUDP(net string, laddr *UDPAddr) (c *UDPConn, err os.Error) {
+func ListenUDP(net string, laddr *UDPAddr) (c *UDPConn, err error) {
switch net {
case "udp", "udp4", "udp6":
default:
return nil, UnknownNetworkError(net)
}
if laddr == nil {
- return nil, &OpError{"listen", "udp", nil, errMissingAddress}
+ return nil, &OpError{"listen", net, nil, errMissingAddress}
}
l, err := listenPlan9(net, laddr)
if err != nil {
@@ -169,19 +187,10 @@ func ListenUDP(net string, laddr *UDPAddr) (c *UDPConn, err os.Error) {
return &UDPConn{*l.plan9Conn()}, nil
}
-// JoinGroup joins the IPv4 multicast group named by addr.
-// The UDPConn must use the "udp4" network.
-func (c *UDPConn) JoinGroup(addr IP) os.Error {
- if !c.ok() {
- return os.EINVAL
- }
- return os.EPLAN9
-}
-
-// LeaveGroup exits the IPv4 multicast group named by addr.
-func (c *UDPConn) LeaveGroup(addr IP) os.Error {
- if !c.ok() {
- return os.EINVAL
- }
- return os.EPLAN9
+// ListenMulticastUDP listens for incoming multicast UDP packets
+// addressed to the group address gaddr on ifi, which specifies
+// the interface to join. ListenMulticastUDP uses default
+// multicast interface if ifi is nil.
+func ListenMulticastUDP(net string, ifi *Interface, gaddr *UDPAddr) (*UDPConn, error) {
+ return nil, syscall.EPLAN9
}