Loading...
Searching...
No Matches
examples/clntsrv/src/client.cc

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

Client/Server example using C++ infrastructure – Client 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 <l4/sys/err.h>
#include <l4/sys/types.h>
#include <l4/re/env>
#include <l4/re/util/cap_alloc>
#include <stdio.h>
#include "shared.h"
int
main()
{
L4::Cap<Calc> server = L4Re::Env::env()->get_cap<Calc>("calc_server");
if (!server.is_valid())
{
printf("Could not get server capability!\n");
return 1;
}
l4_uint32_t val1 = 8;
l4_uint32_t val2 = 5;
printf("Asking for %d - %d\n", val1, val2);
if (server->sub(val1, val2, &val1))
{
printf("Error talking to server\n");
return 1;
}
printf("Result of subtract call: %d\n", val1);
printf("Asking for -%d\n", val1);
if (server->neg(val1, &val1))
{
printf("Error talking to server\n");
return 1;
}
printf("Result of negate call: %d\n", val1);
return 0;
}
L4Re::Env::env
static Env const * env() noexcept
Returns the initial environment for the current task.
Definition env:96
L4Re::Env::get_cap
L4::Cap< T > get_cap(char const *name, unsigned l) const noexcept
Get the capability selector for the object named name.
Definition env:197
L4::Cap
C++ interface for capabilities.
Definition capability.h:224
env
Environment interface.
err.h
Error codes.
l4_uint32_t
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:29
types.h
Common L4 ABI Data Types.
cap_alloc
Capability allocator.