OLD | NEW |
1 // Copyright 2010 The Go Authors. All rights reserved. | 1 // Copyright 2010 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 // Package jsonrpc implements a JSON-RPC ClientCodec and ServerCodec | 5 // Package jsonrpc implements a JSON-RPC ClientCodec and ServerCodec |
6 // for the rpc package. | 6 // for the rpc package. |
7 package jsonrpc | 7 package jsonrpc |
8 | 8 |
9 import ( | 9 import ( |
| 10 "encoding/json" |
10 "fmt" | 11 "fmt" |
11 "io" | 12 "io" |
12 "json" | |
13 "net" | 13 "net" |
14 » "rpc" | 14 » "net/rpc" |
15 "sync" | 15 "sync" |
16 ) | 16 ) |
17 | 17 |
18 type clientCodec struct { | 18 type clientCodec struct { |
19 dec *json.Decoder // for reading JSON values | 19 dec *json.Decoder // for reading JSON values |
20 enc *json.Encoder // for writing JSON values | 20 enc *json.Encoder // for writing JSON values |
21 c io.Closer | 21 c io.Closer |
22 | 22 |
23 // temporary work space | 23 // temporary work space |
24 req clientRequest | 24 req clientRequest |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 114 } |
115 | 115 |
116 // Dial connects to a JSON-RPC server at the specified network address. | 116 // Dial connects to a JSON-RPC server at the specified network address. |
117 func Dial(network, address string) (*rpc.Client, error) { | 117 func Dial(network, address string) (*rpc.Client, error) { |
118 conn, err := net.Dial(network, address) | 118 conn, err := net.Dial(network, address) |
119 if err != nil { | 119 if err != nil { |
120 return nil, err | 120 return nil, err |
121 } | 121 } |
122 return NewClient(conn), err | 122 return NewClient(conn), err |
123 } | 123 } |
OLD | NEW |