Hello folks,
I have implemented a JNI layer for communication between the Android
Java Application and Android Native C code.
However, we are facing issues with IPC in this JNI layer.
I tried the following IPC approaches:
1. Socket in JNI layer: C Sockets to communicate with the underlying C
based processes.
I get an error in bind().
Sample code:
fd_recv_es = socket(AF_INET,SOCK_DGRAM,0);
if (0 > fd_recv_es)
{
return (FAILURE);
}
bzero(&es_recv_addr, sizeof(es_recv_addr));
es_recv_addr.sin_family = AF_INET;
es_recv_addr.sin_port = htons(self_port);
es_recv_addr.sin_addr.s_addr = inet_addr(self_ip.str);
memset(&(es_recv_addr.sin_zero), '\0', 8);
if ( -1 == bind( fd_recv_es,(struct sockaddr*)(&es_recv_addr),
sizeof(struct sockaddr_in))) // Fails here
{
return (FAILURE);
}
2. Message Q in JNI layer: Linux based message queue to communicate
with the underlying C based processes.
I get an error in creating the
message queue.
Sample Code:
struct my_msgbuf buf;
int msqid, i;
key_t key;
if ((key = ftok("/data/IPC/dummy", 'B')) == -1)
{
perror("ftok");
exit(1);
}
if ((msqid = msgget(key, 0644 | IPC_CREAT)) == -1) // Fails
here
{
perror("msgget");
exit(1);
}
Both these approaches work perfectly fine when I use them in an
Android C executable,
and we are getting this problem only when we use them in a JNI DLL.
The linking command for the building JNI DLL is:
ALIB := $(NDK_BASE)/toolchain/arm-eabi/lib/gcc/arm-eabi/4.2.1/
libgcc.a
$(CC) -nostdlib -Wl,-soname,libApp.so -Wl,-shared,-Bsymbolic
-L$(NDK_BASE)/lib $^ $(LIBS) -o libApp.so -Wl,--no-undefined
$(ALIB)
Has anyone faced a similar issues with IPC(with C executables) in JNI
layer?
Also, are there are some other flags required for building a JNI DLL
that I've missed out on.
Any pointers in this direction shall be really helpful.
Thanks,
Pankaj
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---