You'll need to add network access permissions to the manifest for the Android application that is loading the shared object.
For the second issue, I had noticed that message queues work fine on the emulator, but fail on target. After a closer examination using strace, I realized that system call SYS_303 is supported on the emulator but not on the target. Stick to socket or some other IPC mechanism. --Ashu On Dec 3, 6:10 am, Pankaj Munjal <[EMAIL PROTECTED]> wrote: > 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 withIPCin this JNI layer. > > I tried the followingIPCapproaches: > > 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 thisproblemonly 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 withIPC(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 android-developers@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---