type StreamServer … type ServerFunc … // ServeStream calls f(ctx, s). func (f ServerFunc) ServeStream(ctx context.Context, c Conn) error { … } // HandlerServer returns a StreamServer that handles incoming streams using the // provided handler. func HandlerServer(h Handler) StreamServer { … } // ListenAndServe starts an jsonrpc2 server on the given address. If // idleTimeout is non-zero, ListenAndServe exits after there are no clients for // this duration, otherwise it exits only on error. func ListenAndServe(ctx context.Context, network, addr string, server StreamServer, idleTimeout time.Duration) error { … } // Serve accepts incoming connections from the network, and handles them using // the provided server. If idleTimeout is non-zero, ListenAndServe exits after // there are no clients for this duration, otherwise it exits only on error. func Serve(ctx context.Context, ln net.Listener, server StreamServer, idleTimeout time.Duration) error { … } // isClosingError reports if the error occurs normally during the process of // closing a network connection. It uses imperfect heuristics that err on the // side of false negatives, and should not be used for anything critical. func isClosingError(err error) bool { … }