LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // TCP for Plan 9 | 5 // TCP for Plan 9 |
6 | 6 |
7 package net | 7 package net |
8 | 8 |
| 9 import ( |
| 10 "os" |
| 11 ) |
| 12 |
9 // TCPConn is an implementation of the Conn interface | 13 // TCPConn is an implementation of the Conn interface |
10 // for TCP network connections. | 14 // for TCP network connections. |
11 type TCPConn struct { | 15 type TCPConn struct { |
12 plan9Conn | 16 plan9Conn |
| 17 } |
| 18 |
| 19 // CloseRead shuts down the reading side of the TCP connection. |
| 20 // Most callers should just use Close. |
| 21 func (c *TCPConn) CloseRead() error { |
| 22 if !c.ok() { |
| 23 return os.EINVAL |
| 24 } |
| 25 return os.EPLAN9 |
| 26 } |
| 27 |
| 28 // CloseWrite shuts down the writing side of the TCP connection. |
| 29 // Most callers should just use Close. |
| 30 func (c *TCPConn) CloseWrite() error { |
| 31 if !c.ok() { |
| 32 return os.EINVAL |
| 33 } |
| 34 return os.EPLAN9 |
13 } | 35 } |
14 | 36 |
15 // DialTCP connects to the remote address raddr on the network net, | 37 // DialTCP connects to the remote address raddr on the network net, |
16 // which must be "tcp", "tcp4", or "tcp6". If laddr is not nil, it is used | 38 // which must be "tcp", "tcp4", or "tcp6". If laddr is not nil, it is used |
17 // as the local address for the connection. | 39 // as the local address for the connection. |
18 func DialTCP(net string, laddr, raddr *TCPAddr) (c *TCPConn, err error) { | 40 func DialTCP(net string, laddr, raddr *TCPAddr) (c *TCPConn, err error) { |
19 switch net { | 41 switch net { |
20 case "tcp", "tcp4", "tcp6": | 42 case "tcp", "tcp4", "tcp6": |
21 default: | 43 default: |
22 return nil, UnknownNetworkError(net) | 44 return nil, UnknownNetworkError(net) |
(...skipping 27 matching lines...) Expand all Loading... |
50 } | 72 } |
51 if laddr == nil { | 73 if laddr == nil { |
52 return nil, &OpError{"listen", "tcp", nil, errMissingAddress} | 74 return nil, &OpError{"listen", "tcp", nil, errMissingAddress} |
53 } | 75 } |
54 l1, err := listenPlan9(net, laddr) | 76 l1, err := listenPlan9(net, laddr) |
55 if err != nil { | 77 if err != nil { |
56 return | 78 return |
57 } | 79 } |
58 return &TCPListener{*l1}, nil | 80 return &TCPListener{*l1}, nil |
59 } | 81 } |
LEFT | RIGHT |