I have a Java application running a C program in a child process. The C program is started using JNI code, which among other things sets up pipes for IPC between the two. The native method returns FileDescriptors which the Java code uses to create a FileInputStream and a FileOutputStream. Using Streams is not satisfactory, and I would very much like to use a Socket instead. This I would want to create from the file descriptor returned by socketpair() in my native code.
I have looked into the code of junixsocket to see if there was a way to use that for my purpose, but at least I am not able to find an easy way of doing it.
Request
Please provide a way to create an AFUNIXSocket from an already open file descriptor. Maybe more info is needed, e.g. to tell that it is a stream or datagram socket, whether it is a listening socket on an already connected socket, etc. Or perhaps junixsocket could get that info using getsockopt().
Background
I have a Java application running a C program in a child process. The C program is started using JNI code, which among other things sets up pipes for IPC between the two. The native method returns
FileDescriptor
s which the Java code uses to create aFileInputStream
and aFileOutputStream
. UsingStream
s is not satisfactory, and I would very much like to use aSocket
instead. This I would want to create from the file descriptor returned bysocketpair()
in my native code. I have looked into the code of junixsocket to see if there was a way to use that for my purpose, but at least I am not able to find an easy way of doing it.Request
Please provide a way to create an
AFUNIXSocket
from an already open file descriptor. Maybe more info is needed, e.g. to tell that it is a stream or datagram socket, whether it is a listening socket on an already connected socket, etc. Or perhaps junixsocket could get that info usinggetsockopt()
.