package rpc

Import Path
	net/rpc (on golang.org and go.dev)

Dependency Relation
	imports 14 packages, and imported by one package

Involved Source Files
	    client.go
	    debug.go
	d-> server.go

Exported Type Names

type Call (struct) Call represents an active RPC. Args interface{} Done chan *Call Error error Reply interface{} ServiceMethod string func (*Client).Go(serviceMethod string, args interface{}, reply interface{}, done chan *Call) *Call func (*Client).Go(serviceMethod string, args interface{}, reply interface{}, done chan *Call) *Call
type Client (struct) Client represents an RPC Client. There may be multiple outstanding Calls associated with a single Client, and a Client may be used by multiple goroutines simultaneously. (*T) Call(serviceMethod string, args interface{}, reply interface{}) error (*T) Close() error (*T) Go(serviceMethod string, args interface{}, reply interface{}, done chan *Call) *Call *T : io.Closer func Dial(network, address string) (*Client, error) func DialHTTP(network, address string) (*Client, error) func DialHTTPPath(network, address, path string) (*Client, error) func NewClient(conn io.ReadWriteCloser) *Client func NewClientWithCodec(codec ClientCodec) *Client func net/rpc/jsonrpc.Dial(network, address string) (*Client, error) func net/rpc/jsonrpc.NewClient(conn io.ReadWriteCloser) *Client
type ClientCodec (interface) A ClientCodec implements writing of RPC requests and reading of RPC responses for the client side of an RPC session. The client calls WriteRequest to write a request to the connection and calls ReadResponseHeader and ReadResponseBody in pairs to read responses. The client calls Close when finished with the connection. ReadResponseBody may be called with a nil argument to force the body of the response to be read and then discarded. See NewClient's comment for information about concurrent access. (T) Close() error (T) ReadResponseBody(interface{}) error (T) ReadResponseHeader(*Response) error (T) WriteRequest(*Request, interface{}) error T : io.Closer func net/rpc/jsonrpc.NewClientCodec(conn io.ReadWriteCloser) ClientCodec func NewClientWithCodec(codec ClientCodec) *Client
type Request (struct) Request is a header written before every RPC call. It is used internally but documented here as an aid to debugging, such as when analyzing network traffic. Seq uint64 ServiceMethod string func ClientCodec.WriteRequest(*Request, interface{}) error func ServerCodec.ReadRequestHeader(*Request) error
type Response (struct) Response is a header written before every RPC return. It is used internally but documented here as an aid to debugging, such as when analyzing network traffic. Error string Seq uint64 ServiceMethod string func ClientCodec.ReadResponseHeader(*Response) error func ServerCodec.WriteResponse(*Response, interface{}) error
type Server (struct) Server represents an RPC Server. (*T) Accept(lis net.Listener) (*T) HandleHTTP(rpcPath, debugPath string) (*T) Register(rcvr interface{}) error (*T) RegisterName(name string, rcvr interface{}) error (*T) ServeCodec(codec ServerCodec) (*T) ServeConn(conn io.ReadWriteCloser) (*T) ServeHTTP(w http.ResponseWriter, req *http.Request) (*T) ServeRequest(codec ServerCodec) error *T : net/http.Handler func NewServer() *Server var DefaultServer *Server
type ServerCodec (interface) A ServerCodec implements reading of RPC requests and writing of RPC responses for the server side of an RPC session. The server calls ReadRequestHeader and ReadRequestBody in pairs to read requests from the connection, and it calls WriteResponse to write a response back. The server calls Close when finished with the connection. ReadRequestBody may be called with a nil argument to force the body of the request to be read and discarded. See NewClient's comment for information about concurrent access. (T) Close() error (T) ReadRequestBody(interface{}) error (T) ReadRequestHeader(*Request) error (T) WriteResponse(*Response, interface{}) error T : io.Closer func net/rpc/jsonrpc.NewServerCodec(conn io.ReadWriteCloser) ServerCodec func ServeCodec(codec ServerCodec) func ServeRequest(codec ServerCodec) error func (*Server).ServeCodec(codec ServerCodec) func (*Server).ServeRequest(codec ServerCodec) error
type ServerError string ServerError represents an error that has been returned from the remote side of the RPC connection. (T) Error() string T : error
Exported Values
func Accept(lis net.Listener) Accept accepts connections on the listener and serves requests to DefaultServer for each incoming connection. Accept blocks; the caller typically invokes it in a go statement.
const DefaultDebugPath = "/debug/rpc"
const DefaultRPCPath = "/_goRPC_" Defaults used by HandleHTTP
var DefaultServer *Server DefaultServer is the default instance of *Server.
func Dial(network, address string) (*Client, error) Dial connects to an RPC server at the specified network address.
func DialHTTP(network, address string) (*Client, error) DialHTTP connects to an HTTP RPC server at the specified network address listening on the default HTTP RPC path.
func DialHTTPPath(network, address, path string) (*Client, error) DialHTTPPath connects to an HTTP RPC server at the specified network address and path.
func HandleHTTP() HandleHTTP registers an HTTP handler for RPC messages to DefaultServer on DefaultRPCPath and a debugging handler on DefaultDebugPath. It is still necessary to invoke http.Serve(), typically in a go statement.
func NewClient(conn io.ReadWriteCloser) *Client NewClient returns a new Client to handle requests to the set of services at the other end of the connection. It adds a buffer to the write side of the connection so the header and payload are sent as a unit. The read and write halves of the connection are serialized independently, so no interlocking is required. However each half may be accessed concurrently so the implementation of conn should protect against concurrent reads or concurrent writes.
func NewClientWithCodec(codec ClientCodec) *Client NewClientWithCodec is like NewClient but uses the specified codec to encode requests and decode responses.
func NewServer() *Server NewServer returns a new Server.
func Register(rcvr interface{}) error Register publishes the receiver's methods in the DefaultServer.
func RegisterName(name string, rcvr interface{}) error RegisterName is like Register but uses the provided name for the type instead of the receiver's concrete type.
func ServeCodec(codec ServerCodec) ServeCodec is like ServeConn but uses the specified codec to decode requests and encode responses.
func ServeConn(conn io.ReadWriteCloser) ServeConn runs the DefaultServer on a single connection. ServeConn blocks, serving the connection until the client hangs up. The caller typically invokes ServeConn in a go statement. ServeConn uses the gob wire format (see package gob) on the connection. To use an alternate codec, use ServeCodec. See NewClient's comment for information about concurrent access.
func ServeRequest(codec ServerCodec) error ServeRequest is like ServeCodec but synchronously serves a single request. It does not close the codec upon completion.