Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 294 Vote(s) - 3.38 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can we use System IPC in android NDK code

#1
Here I want to use System IPCs methods like

<sys/msg.h> /* SysV message queues */
<sys/ipc.h> /* General IPC definitions */

Here my android NDK code is in C language and I used message queue IPC mechanism for communication for other C application.

So please Let me know is there any way to achieve this IPC goal?
How can I implement this IPC mechanism in android NDK code?
Reply

#2
One year ago I wrote a survey about this topic. Here is a part of it:

2 Unix IPC mechanisms

Unix IPC mechanisms include:

- Unix signals.
- Unix pipes.
- Unix domain sockets.

At the same time Unix System-V IPC mechanisms are not included in Android.
Bionic intentionally does not provide support for System-V IPCs mechanisms, like the
ones provided by semget(), shmget(), msgget(). The reason for this is to avoid denial-
of-service [11].

2.1 Unix signals

One of the best explanations how unix signals work we can find in [wikipedia][1]: “A
signal is a limited form of inter-process communication used in Unix, Unix-like, and
other POSIX-compliant operating systems. Essentially it is an asynchronous notifica-
tion sent to a process in order to notify it of an event that occurred. When a signal is
sent to a process, the operating system interrupts the process’s normal flow of execu-
tion. Execution can be interrupted during any non-atomic instruction. If the process has
previously registered a signal handler, that routine is executed. Otherwise the default
signal handler is executed.”
It seems that unix signals are rearly used in Android programming. Moreover,
some signals have been disabled in [debug mode][2]. However, it is a possible IPC
mechanism.

2.2 Unix pipes

Pipe is a communication mechanism that allows to connect directly the output stream
of one process with the input stread of another process. There are two types of unix
pipes: named pipes and unnamed pipes. It seems that in Android programming only
named pipes are used. In this case two processes interact using a special file that
connects the output and input. It should be mentioned that pipe is one-direction way
of communication, i.e. one process is always reader and the second is always writer.
The communication file has to be created on Linux filesystem, because sdcard’s FAT32
does not allow to create pipe. Here is an example how a named unix pipe can be created
and used in [Android][3] (In Russian). The source code for this example can be found [here][4].

2.3 Unix domain sockets

Unix domain sockets, on the contrary of unix pipes, allow to tranfer information in
both ways: from server to client and from client to server. Unix domain sockets
and unix pipes use file system as address name space. That means that server and
client use special file to establish communication. Considering Android there are two
classes that are used to program unix domain sockets: LocalServerSocket and
LocalSocket. All the implementation can be built around these two classes and it is
not required to use native code to make a unix domain socket. A simple example how
to use unix domain sockets is shown [here][5].

[11] Android ndk documentation. NDK documentation for android-ndk-r6b


[1]:

[To see links please register here]

[2]:

[To see links please register here]

[3]:

[To see links please register here]

[4]:

[To see links please register here]

[5]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through