I see these threads UNIX socket implementation for Java? and http://forums.sun.com/thread.jspa?threadID=713266.
The second link says that Java already supports UNIX Domain Socket. If that's true what class do I need to implement from Java?.
From the first link, it says that Java does not support UNIX Domain Socket. If you need UNIX Domain Socket you must use a 3rd-party library.
So, which is it?
Examining Unix Domain Sockets. To list all listening Unix Domain Sockets, run the ss -xln command. The x flag ensures that only domain sockets are displayed. Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process . . . u_str LISTEN 0 5 /tmp/stream.
A Unix domain socket aka UDS or IPC socket (inter-process communication socket) is a data communications endpoint for exchanging data between processes executing on the same host operating system. It is also referred to by its address family AF_UNIX .
Unix sockets are bidirectional. This means that every side can perform both read and write operations. While, FIFOs are unidirectional: it has a writer peer and a reader peer. Unix sockets create less overhead and communication is faster, than by localhost IP sockets.
To create a UNIX domain socket, use the socket function and specify AF_UNIX as the domain for the socket. The z/TPF system supports a maximum number of 16,383 active UNIX domain sockets at any time. After a UNIX domain socket is created, you must bind the socket to a unique file path by using the bind function.
You could use junixsocket: https://github.com/kohlschutter/junixsocket
It provides AF-UNIX support via a JNI library, utilizing the Java Socket API. It even allows connecting to MySQL from Java (Connector/J) via Unix sockets.
Java cannot create or access Unix Domain Sockets without using a 3rd party (native) library. The last comment on the second link above mentions this.
The first link has some good (and correct) information on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With