Java 中的 UNIX 域套接字
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4099432/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
UNIX Domain Socket in Java
提问by korrawit
I see these threads UNIX socket implementation for Java?and http://forums.sun.com/thread.jspa?threadID=713266.
我看到这些线程是 Java 的 UNIX 套接字实现吗?和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?.
第二个链接说 Java 已经支持 UNIX Domain Socket。如果这是真的,我需要从 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.
从第一个链接,它说 Java 不支持 UNIX 域套接字。如果您需要 UNIX 域套接字,则必须使用第 3 方库。
So, which is it?
那么,它是哪个?
采纳答案by nogudnik
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.
如果不使用第 3 方(本机)库,Java 无法创建或访问 Unix 域套接字。上面第二个链接的最后一条评论提到了这一点。
The first link has some good (and correct) information on it.
第一个链接上有一些好的(和正确的)信息。
回答by Christian Kohlschütter
You could use junixsocket: https://github.com/kohlschutter/junixsocket
您可以使用 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 Socket API 通过 JNI 库提供 AF-UNIX 支持。它甚至允许通过 Unix 套接字从 Java (Connector/J) 连接到 MySQL。
回答by Leo Gomes
Netty also supports it since version 4.0.26: https://github.com/netty/netty/pull/3344
Netty 从 4.0.26 版本开始也支持它:https: //github.com/netty/netty/pull/3344