The Pedigree Project
0.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
user
applications
ipc-test-client
user/applications/ipc-test-client/main.cc
1
/*
2
* Copyright (c) 2008-2014, Pedigree Developers
3
*
4
* Please see the CONTRIB file in the root of the source tree for a full
5
* list of contributors.
6
*
7
* Permission to use, copy, modify, and distribute this software for any
8
* purpose with or without fee is hereby granted, provided that the above
9
* copyright notice and this permission notice appear in all copies.
10
*
11
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
*/
19
20
#include "pedigree/native/ipc/Ipc.h"
21
#include <stdio.h>
22
23
#include <sys/klog.h>
24
25
using namespace
PedigreeIpc
;
26
27
int
main(
int
argc,
char
*argv[])
28
{
29
printf(
"IPC Test: Client\n"
);
30
31
// Grab an endpoint to use.
32
createEndpoint(
"ipc-test"
);
33
IpcEndpoint *pEndpoint = getEndpoint(
"ipc-test"
);
34
35
// Create a "Hello World!" message.
36
IpcMessage
*pMessage =
new
IpcMessage
();
37
38
if
(!pMessage)
39
klog(LOG_ERR,
"operator new returned null"
);
40
41
if
(!pMessage->initialise())
42
{
43
printf(
"Message couldn't be initialised.\n"
);
44
return
1;
45
}
46
47
char
*pBuffer =
reinterpret_cast<
char
*
>
(pMessage->getBuffer());
48
if
(!pBuffer)
49
{
50
printf(
"Message creation failed.\n"
);
51
return
1;
52
}
53
else
54
printf(
"Writing into message %x\n"
, pBuffer);
55
56
sprintf(pBuffer,
"Hello, world!\n"
);
57
58
printf(
"Sending message...\n"
);
59
60
// Send the message.
61
send(pEndpoint, pMessage,
false
);
62
63
printf(
"Message has been sent, waiting for response...\n"
);
64
65
// Wait for a response from the IPC test server.
66
IpcMessage
*pRecv = 0;
67
recv(pEndpoint, &pRecv,
false
);
68
69
// Display it.
70
printf(
"Got '%s' from the IPC server.\n"
, pRecv->getBuffer());
71
72
// Clean up.
73
delete
pMessage;
74
delete
pRecv;
75
76
// All done.
77
printf(
"IPC Test: Client completed.\n"
);
78
79
return
0;
80
}
PedigreeIpc::StandardIpcMessage
A standard IPC message that is less than 4 KB in size.
Definition:
modules/subsys/native/include/pedigree/native/ipc/Ipc.h:29
PedigreeIpc
Definition:
modules/subsys/native/include/pedigree/native/ipc/Ipc.h:26
Generated on Fri Jan 24 2020 06:46:14 for The Pedigree Project by
1.8.11