Yochai Timmer
Yochai Timmer

Reputation: 49261

What path can I use with boost::asio::local::stream_protocol on Android?

I'm trying to open a local socket on Android via boost's wrapper for Unix Domain sockets.

I can't seem to find a path where the acceptor works.

using boost::asio::local::stream_protocol;

void test()
{
   boost::asio::io_service io;
   stream_protocol::endpoint ep("/dev/shm/BlahBLah");
   stream_protocol::acceptor(io, ep);
}

I get an exception from the sock bind() with error code: 2 (ENOENT)

So, why can't the boost stream_protocol connect through that directory ? (Manually I could open a and bind socket to that path)

Do I need to set permissions somehow? or is there a different path that would work (Not through the SD card, I need a virtual path)

Upvotes: 0

Views: 838

Answers (1)

sehe
sehe

Reputation: 393427

It seems funny to use the shared memory device in the first place.

UNIX domain sockets are unrelated to it. I believe Android kernels don't support shared memory.

I think you should be able use any directory that is accessible and writable to the program.

What does it mean "I need a virtual path"? I suppose you mean you want the socket to be invisible¹? Posix permission or acls should be used for that.

Finally, look at socketpair which - IIRC - creates unnamed sockets for IPC


¹ Chances are that /proc, lsof and similar still see it. Don't expose secrets in the name of the socket and protect it using permissions.

Upvotes: 0

Related Questions