OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [net/] [tcpsock_plan9.go] - Blame information for rev 747

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2009 The Go Authors.  All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
 
5
// TCP for Plan 9
6
 
7
package net
8
 
9
import (
10
        "os"
11
        "time"
12
)
13
 
14
// TCPConn is an implementation of the Conn interface
15
// for TCP network connections.
16
type TCPConn struct {
17
        plan9Conn
18
}
19
 
20
// SetDeadline implements the Conn SetDeadline method.
21
func (c *TCPConn) SetDeadline(t time.Time) error {
22
        return os.EPLAN9
23
}
24
 
25
// SetReadDeadline implements the Conn SetReadDeadline method.
26
func (c *TCPConn) SetReadDeadline(t time.Time) error {
27
        return os.EPLAN9
28
}
29
 
30
// SetWriteDeadline implements the Conn SetWriteDeadline method.
31
func (c *TCPConn) SetWriteDeadline(t time.Time) error {
32
        return os.EPLAN9
33
}
34
 
35
// CloseRead shuts down the reading side of the TCP connection.
36
// Most callers should just use Close.
37
func (c *TCPConn) CloseRead() error {
38
        if !c.ok() {
39
                return os.EINVAL
40
        }
41
        return os.EPLAN9
42
}
43
 
44
// CloseWrite shuts down the writing side of the TCP connection.
45
// Most callers should just use Close.
46
func (c *TCPConn) CloseWrite() error {
47
        if !c.ok() {
48
                return os.EINVAL
49
        }
50
        return os.EPLAN9
51
}
52
 
53
// DialTCP connects to the remote address raddr on the network net,
54
// which must be "tcp", "tcp4", or "tcp6".  If laddr is not nil, it is used
55
// as the local address for the connection.
56
func DialTCP(net string, laddr, raddr *TCPAddr) (c *TCPConn, err error) {
57
        switch net {
58
        case "tcp", "tcp4", "tcp6":
59
        default:
60
                return nil, UnknownNetworkError(net)
61
        }
62
        if raddr == nil {
63
                return nil, &OpError{"dial", net, nil, errMissingAddress}
64
        }
65
        c1, err := dialPlan9(net, laddr, raddr)
66
        if err != nil {
67
                return
68
        }
69
        return &TCPConn{*c1}, nil
70
}
71
 
72
// TCPListener is a TCP network listener.
73
// Clients should typically use variables of type Listener
74
// instead of assuming TCP.
75
type TCPListener struct {
76
        plan9Listener
77
}
78
 
79
// ListenTCP announces on the TCP address laddr and returns a TCP listener.
80
// Net must be "tcp", "tcp4", or "tcp6".
81
// If laddr has a port of 0, it means to listen on some available port.
82
// The caller can use l.Addr() to retrieve the chosen address.
83
func ListenTCP(net string, laddr *TCPAddr) (l *TCPListener, err error) {
84
        switch net {
85
        case "tcp", "tcp4", "tcp6":
86
        default:
87
                return nil, UnknownNetworkError(net)
88
        }
89
        if laddr == nil {
90
                return nil, &OpError{"listen", net, nil, errMissingAddress}
91
        }
92
        l1, err := listenPlan9(net, laddr)
93
        if err != nil {
94
                return
95
        }
96
        return &TCPListener{*l1}, nil
97
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.