Re: using unix domain sockets

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: using unix domain sockets

Ajit Kumar
David, do you have an example for the java code for dalvik vm. Do you use java.net.Socket/ServerSocket or android.net.LocalSocket/LocalServerSocket?

On Friday, March 30, 2012 6:30:12 AM UTC-7, David Given wrote:
Chris Stratton wrote:
[...]
> There is no requirement that both sockets be in the same process.  In
> the most common use cases, they they are not.

We're using Unix sockets to communicate between two processes (one side
is a Dalvik VM, the other is a daemon process started with fork), and it
all works fine.

However, bear in mind that a Java LocalSocketAddress actually refers to
an abstract socket address, not a filesystem one --- from the C side,
the first byte of the address must be a \0. See the man page.

--
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│ "Parents let children ride bicycles on the street. But parents do not
│ allow children to hear vulgar words. Therefore we can deduce that
│ cursing is more dangerous than being hit by a car." --- Scott Adams

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/i-VTzJDmH-wJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: using unix domain sockets

David Given
Ajit Kumar wrote:
> David, do you have an example for the java code for dalvik vm. Do you
> use java.net.Socket/ServerSocket or
> android.net.LocalSocket/LocalServerSocket?

Sorry, I should have been clearer: both sides of our code are native, so
we're not using Java. I have used androdi.net.LocalSocket in the past
but don't have any code handy, sorry.

(You have to use android.net.LocalSocket as java.net.Socket doesn't
support Unix domain sockets. However... there's nothing to stop you
connecting to localhost if you prefer to use Socket: it's marginally
less efficient than a Unix domain socket, but only very slightly.)

--
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│ "There is nothing in the world so dangerous --- and I mean *nothing*
│ --- as a children's story that happens to be true." --- Master Li Kao,
│ _The Bridge of Birds_


signature.asc (271 bytes) Download Attachment