n = 1000
}
switch runtime.GOOS {
- case "darwin", "freebsd", "netbsd", "openbsd", "windows":
+ case "darwin", "freebsd", "netbsd", "openbsd", "plan9", "windows":
// Non-Linux systems take a long time to figure
// out that there is nothing listening on localhost.
n = 100
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// +build !plan9
+
package net
import (
"time"
)
+// /sys/include/ape/sys/socket.h:/SOMAXCONN
+var listenerBacklog = 5
+
// probeIPv6Stack returns two boolean values. If the first boolean value is
// true, kernel supports basic IPv6 functionality. If the second
// boolean value is true, kernel supports IPv6 IPv4-mapping.
if err != nil {
return
}
+ defer f.Close()
n, err := f.Read(buf[:])
if err != nil {
return
var buf [16]byte
n, err := f.Read(buf[:])
if err != nil {
+ f.Close()
return
}
return f, dest, proto, string(buf[:n]), nil
}
_, err = f.WriteString("connect " + dest)
if err != nil {
+ f.Close()
return
}
laddr, err = readPlan9Addr(proto, "/net/"+proto+"/"+name+"/local")
if err != nil {
+ f.Close()
return
}
raddr, err = readPlan9Addr(proto, "/net/"+proto+"/"+name+"/remote")
if err != nil {
+ f.Close()
return
}
return newPlan9Conn(proto, name, f, laddr, raddr), nil
}
_, err = f.WriteString("announce " + dest)
if err != nil {
+ f.Close()
return
}
laddr, err = readPlan9Addr(proto, "/net/"+proto+"/"+name+"/local")
if err != nil {
+ f.Close()
return
}
l = new(plan9Listener)
var buf [16]byte
n, err := f.Read(buf[:])
if err != nil {
+ f.Close()
return
}
name := string(buf[:n])
laddr, err := readPlan9Addr(l.proto, l.dir+"/local")
if err != nil {
+ f.Close()
return
}
raddr, err := readPlan9Addr(l.proto, l.dir+"/remote")
if err != nil {
+ f.Close()
return
}
return newPlan9Conn(l.proto, name, f, laddr, raddr), nil
}
func (l *plan9Listener) Addr() Addr { return l.laddr }
+
+// SetDeadline sets the deadline associated with the listener.
+// A zero time value disables the deadline.
+func (l *plan9Listener) SetDeadline(t time.Time) error {
+ return syscall.EPLAN9
+}
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// +build !plan9
+
package net
import (
}
func TestUDPListenClose(t *testing.T) {
+ switch runtime.GOOS {
+ case "plan9":
+ t.Logf("skipping test on %q", runtime.GOOS)
+ return
+ }
ln, err := ListenPacket("udp", "127.0.0.1:0")
if err != nil {
t.Fatalf("Listen failed: %v", err)
package net
-import (
- "syscall"
- "time"
-)
+import "syscall"
// TCPConn is an implementation of the Conn interface
// for TCP network connections.
plan9Conn
}
-// SetDeadline implements the Conn SetDeadline method.
-func (c *TCPConn) SetDeadline(t time.Time) error {
- return syscall.EPLAN9
-}
-
-// SetReadDeadline implements the Conn SetReadDeadline method.
-func (c *TCPConn) SetReadDeadline(t time.Time) error {
- return syscall.EPLAN9
-}
-
-// SetWriteDeadline implements the Conn SetWriteDeadline method.
-func (c *TCPConn) SetWriteDeadline(t time.Time) error {
- return syscall.EPLAN9
-}
-
// CloseRead shuts down the reading side of the TCP connection.
// Most callers should just use Close.
func (c *TCPConn) CloseRead() error {
plan9Listener
}
+func (l *TCPListener) Close() error {
+ if l == nil || l.ctl == nil {
+ return syscall.EINVAL
+ }
+ if _, err := l.ctl.WriteString("hangup"); err != nil {
+ l.ctl.Close()
+ return err
+ }
+ return l.ctl.Close()
+}
+
// ListenTCP announces on the TCP address laddr and returns a TCP listener.
// Net must be "tcp", "tcp4", or "tcp6".
// If laddr has a port of 0, it means to listen on some available port.
package net
+import "errors"
+
+var ErrWriteToConnected = errors.New("use of WriteTo with pre-connected UDP")
+
// UDPAddr represents the address of a UDP end point.
type UDPAddr struct {
IP IP
"errors"
"os"
"syscall"
- "time"
)
// UDPConn is the implementation of the Conn and PacketConn
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.
package net
-import (
- "errors"
- "syscall"
-)
-
-var ErrWriteToConnected = errors.New("use of WriteTo with pre-connected UDP")
+import "syscall"
func sockaddrToUDP(sa syscall.Sockaddr) Addr {
switch sa := sa.(type) {
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// +build !plan9
+
package net
import (