Tag: unix domain sockets

直接从/ dev / log Unix Domain Socket读取数据

我的项目旨在直接从Java中的/dev/log UNIX域套接字读取日志消息。 目前我正在使用junixsocket 。 下面是从unix套接字读取的客户端示例代码。 import java.io.File; import java.io.IOException; import java.io.InputStream; import org.newsclub.net.unix.AFUNIXSocket; import org.newsclub.net.unix.AFUNIXSocketAddress; import org.newsclub.net.unix.AFUNIXSocketException; public class SimpleTestClient { public static void main(String[] args) throws IOException { final File socketFile = new File(“/dev/log”); AFUNIXSocket sock = AFUNIXSocket.newInstance(); try { sock.connect(new AFUNIXSocketAddress(socketFile)); } catch (AFUNIXSocketException e) { System.out.println(“Cannot connect to server. Have you started […]