Reprint Please specify source: http://blog.csdn.net/xiexh0921/article/details/7513628 ############################################## Objective: To implement socket communication between the local C program and APK. Principle: There is no network communication involved, so use the Android package of the local socket to more simple reference: System source code RIL module collation: andy.xie############################################# ##
C Program Service side:
1) server_fd = Socket_local_server (Socket_name_xxh,
android_socket_namespace_abstract, Sock_stream); 2) S_fdlisten = Listen (SERVER_FD, 4); 3) while (Soc Ket = accept (SERVER_FD, NULL, NULL)) > 0)
C Client:1) fd = Socket_local_client (Socket_name_xxh, Android_socket_namespace_abstract, Sock_stream); 2) Write (fd, "Hello", 5);
JAVA Client:1) localsocket = new Localsocket (); 2) Localsocket.connect (new Localsocketaddress (socketaddress)); 3) OutputStream OS = Localsocket.getoutputstream ();
Namespace:Localsocketaddress.namespace abstract A socket in the Linux abstract Namespace localsocketaddress.namespace filesyste M a socket named with A normal filesystem path.
Localsocketaddress.namespace reserved a socket in the Android RESERVED Namespace in/dev/socket.