L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
examples/clntsrv/server.cc

Client/Server example using C++ infrastructure – Server implementation.

Client/Server example using C++ infrastructure – Server implementation.

/*
* (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
* Alexander Warg <warg@os.inf.tu-dresden.de>
* economic rights: Technische Universität Dresden (Germany)
*
* This file is part of TUD:OS and distributed under the terms of the
* GNU General Public License 2.
* Please see the COPYING-GPL-2 file for details.
*/
#include <stdio.h>
#include <l4/re/env>
#include <l4/re/util/object_registry>
#include <l4/re/util/br_manager>
#include <l4/sys/cxx/ipc_epiface>
#include "shared.h"
class Calculation_server : public L4::Epiface_t<Calculation_server, Calc>
{
public:
int op_sub(Calc::Rights, l4_uint32_t a, l4_uint32_t b, l4_uint32_t &res)
{
res = a - b;
return 0;
}
int op_neg(Calc::Rights, l4_uint32_t a, l4_uint32_t &res)
{
res = -a;
return 0;
}
};
int
main()
{
static Calculation_server calc;
// Register calculation server
if (!server.registry()->register_obj(&calc, "calc_server").is_valid())
{
printf("Could not register my service, is there a 'calc_server' in the caps table?\n");
return 1;
}
printf("Welcome to the calculation server!\n"
"I can do subtractions and negations.\n");
// Wait for client requests
server.loop();
return 0;
}
L4::Cap< void > register_obj(L4::Epiface *o, char const *service) override
Register a new server object to a pre-allocated receive endpoint.
A server loop object which has a Object_registry included.
Object_registry const * registry() const
Return registry of this server loop.
void L4_NORETURN loop(l4_utcb_t *utcb=l4_utcb())
Start the server loop.
Environment interface.
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:40
Epiface implementation for Kobject-based interface implementations.
Definition ipc_epiface:515
Capability allocator.