// ServeAddService serves the given AddService backend implementation on conn. func ServeAddService(conn net.Conn, backend AddService) error { srv := rpc.NewServer() if err := srv.RegisterName("AddService", backend); err != nil { return err } srv.ServeCodec(codec.NewServerCodec(conn)) return nil }
// ServeLearner serves the given Learner backend implementation on conn. func ServeLearner(conn net.Conn, backend Learner) error { srv := rpc.NewServer() if err := srv.RegisterName("Learner", backend); err != nil { return err } srv.ServeCodec(codec.NewServerCodec(conn)) return nil }
// ListenAndServeAddService serves the given AddService backend implementation // on all connections accepted as a result of listening on addr (TCP). func ListenAndServeAddService(addr string, backend AddService) error { clients, err := net.Listen("tcp", addr) if err != nil { return err } srv := rpc.NewServer() if err := srv.RegisterName("AddService", backend); err != nil { return err } for { conn, err := clients.Accept() if err != nil { return err } go srv.ServeCodec(codec.NewServerCodec(conn)) } panic("unreachable") }