title: How to connect to Unix Domain Socket on client side service knowing only socket file descriptor
body: <p>My <strong>Service A</strong> communicates with another <strong>Service B</strong> on the same host through <em>UNIX Domain Socket (UDS)</em>. The only information I have is a value of socket file descriptor with which the <strong>Service B</strong> is ready to send data through socket to <strong>Service A</strong>. I use 3rd party library <strong>junixsocket</strong> to communicate through <strong>UDS</strong> between services. And my question is how using this library I can connect to the socket on <strong>Service A</strong> side knowing only the socket file descriptor?</p>
  <p>I just found how to connect to socket on <strong>Service A</strong> side with socketPath:</p>
  <p><code>File socketFile = new File(&quot;/path/to/your/socket&quot;);  AFUNIXSocket sock = AFUNIXSocket.newInstance(); sock.connect(new AFUNIXSocketAddress(socketFile));</code></p>
  <p>But I need to know how to connect to it with just file descriptor</p>
  <p>I’m using openJDK-11, that’s why I have to use 3rd party library for UDS communication</p>