Пример #1
0
func NewServer(root string, l net.Listener) (*Server, error) {
	srv := &Server{
		stdfs:  std.New(root),
		rpcSrv: rpc.NewServer(),
	}

	srv.rpcSrv.Register("RemoteFS", srv)
	go srv.rpcSrv.Accept(l)

	return srv, nil
}
Пример #2
0
func NewTCPServer(root, hostport string) (*Server, error) {
	srv := &Server{
		stdfs:  std.New(root),
		rpcSrv: rpc.NewServer(),
	}

	srv.rpcSrv.Register("RemoteFS", srv)
	srv.rpcSrv.TCPListen(hostport)

	return srv, nil
}
Пример #3
0
func NewServer(hostport, root string) (*Server, error) {
	s := &Server{
		srv:    newServer(root),
		rpcSrv: rpc.NewServer(),
	}

	err := s.rpcSrv.Register("SyncServer", s.srv)
	if err != nil {
		return nil, err
	}

	l, err := net.Listen("tcp", hostport)
	if err != nil {
		return nil, err
	}

	go s.rpcSrv.Accept(l)

	return s, nil
}