Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UNIX Domain Socket in Java

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?

like image 956
korrawit Avatar asked Nov 04 '10 17:11

korrawit


People also ask

How do I find my domain socket Unix?

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.

What is Unix domain stream socket?

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 .

How do UNIX domain sockets work?

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.

How do I create a domain socket in Unix?

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.


2 Answers

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.

like image 198
Christian Kohlschütter Avatar answered Oct 28 '22 11:10

Christian Kohlschütter


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.

like image 28
nogudnik Avatar answered Oct 28 '22 10:10

nogudnik