diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-09-16 15:47:21 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-09-16 15:47:21 +0000 |
commit | 49b4e44b7d540fa846d353b10237848a67789cbf (patch) | |
tree | ea2b52e3c258d6b6d9356977c683c7f72a4a5fd5 /libgo/go/net/tcpsock_plan9.go | |
parent | 82ceb8f6a88a0193971f53e0571e017f2764f7d7 (diff) | |
download | gcc-49b4e44b7d540fa846d353b10237848a67789cbf.tar.gz |
Update Go library to r60.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178910 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/net/tcpsock_plan9.go')
-rw-r--r-- | libgo/go/net/tcpsock_plan9.go | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/libgo/go/net/tcpsock_plan9.go b/libgo/go/net/tcpsock_plan9.go new file mode 100644 index 00000000000..f4f6e9fee16 --- /dev/null +++ b/libgo/go/net/tcpsock_plan9.go @@ -0,0 +1,63 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// TCP for Plan 9 + +package net + +import ( + "os" +) + +// TCPConn is an implementation of the Conn interface +// for TCP network connections. +type TCPConn struct { + plan9Conn +} + +// DialTCP connects to the remote address raddr on the network net, +// which must be "tcp", "tcp4", or "tcp6". If laddr is not nil, it is used +// as the local address for the connection. +func DialTCP(net string, laddr, raddr *TCPAddr) (c *TCPConn, err os.Error) { + switch net { + case "tcp", "tcp4", "tcp6": + default: + return nil, UnknownNetworkError(net) + } + if raddr == nil { + return nil, &OpError{"dial", "tcp", nil, errMissingAddress} + } + c1, err := dialPlan9(net, laddr, raddr) + if err != nil { + return + } + return &TCPConn{*c1}, nil +} + +// TCPListener is a TCP network listener. +// Clients should typically use variables of type Listener +// instead of assuming TCP. +type TCPListener struct { + plan9Listener +} + +// 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. +// The caller can use l.Addr() to retrieve the chosen address. +func ListenTCP(net string, laddr *TCPAddr) (l *TCPListener, err os.Error) { + switch net { + case "tcp", "tcp4", "tcp6": + default: + return nil, UnknownNetworkError(net) + } + if laddr == nil { + return nil, &OpError{"listen", "tcp", nil, errMissingAddress} + } + l1, err := listenPlan9(net, laddr) + if err != nil { + return + } + return &TCPListener{*l1}, nil +} |