本文整理汇总了Java中org.newsclub.net.unix.AFUNIXServerSocket类的典型用法代码示例。如果您正苦于以下问题:Java AFUNIXServerSocket类的具体用法?Java AFUNIXServerSocket怎么用?Java AFUNIXServerSocket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AFUNIXServerSocket类属于org.newsclub.net.unix包,在下文中一共展示了AFUNIXServerSocket类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: run
import org.newsclub.net.unix.AFUNIXServerSocket; //导入依赖的package包/类
public void run() throws IOException {
final File socketFile = new File(path);
socketFile.deleteOnExit();
final ExecutorService executorService = Executors.newCachedThreadPool();
try (AFUNIXServerSocket server = AFUNIXServerSocket.newInstance()) {
server.bind(new AFUNIXSocketAddress(socketFile));
System.out.println("server: " + server);
while (!Thread.interrupted()) {
System.out.println("Waiting for connection...");
executorService.execute(new ClientConnection(this, server.accept()));
}
} finally {
executorService.shutdown();
}
}
开发者ID:avast,项目名称:hdfs-shell,代码行数:19,代码来源:UnixServer.java
示例2: producer
import org.newsclub.net.unix.AFUNIXServerSocket; //导入依赖的package包/类
@Override
public void producer(int nbConsumers) {
try {
final File socketFile = new File(new File(System
.getProperty("java.io.tmpdir")), "junixsocket-test.sock");
AFUNIXServerSocket server = AFUNIXServerSocket.newInstance();
server.bind(new AFUNIXSocketAddress(socketFile));
SenderThread thread = new SenderThread(nbConsumers);
int c = nbConsumers;
while (c > 0) {
c--;
Socket socket = server.accept();
thread.add(socket);
}
thread.start();
server.close();
} catch (IOException e) {
e.printStackTrace();
}
}
开发者ID:intigonzalez,项目名称:shared-memory-queue,代码行数:25,代码来源:UnixSocketsRawMessage.java
示例3: create
import org.newsclub.net.unix.AFUNIXServerSocket; //导入依赖的package包/类
@Override
public void create(@NotNull SharedContext context) throws IOException {
if (!isSupported()) {
log.error("Domain sockets is not supported on this platform. Socket configuration is ignored.");
return;
}
final AFUNIXServerSocket socket = AFUNIXServerSocket.newInstance();
final File socketFile = ConfigHelper.joinPath(context.getBasePath(), path);
//noinspection ResultOfMethodCallIgnored
socketFile.getParentFile().mkdirs();
if (socketFile.exists()) {
//noinspection ResultOfMethodCallIgnored
socketFile.delete();
}
socket.bind(new AFUNIXSocketAddress(socketFile));
context.add(SocketRpc.class, new SocketRpc(context, socket));
}
开发者ID:bozaro,项目名称:git-as-svn,代码行数:18,代码来源:SocketConfig.java
示例4: main
import org.newsclub.net.unix.AFUNIXServerSocket; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
final File socketFile =
new File(new File(System.getProperty("java.io.tmpdir")), "junixsocket-test.sock");
try (AFUNIXServerSocket server = AFUNIXServerSocket.newInstance()) {
server.bind(new AFUNIXSocketAddress(socketFile));
System.out.println("server: " + server);
while (!Thread.interrupted()) {
System.out.println("Waiting for connection...");
try (Socket sock = server.accept()) {
System.out.println("Connected: " + sock);
try (InputStream is = sock.getInputStream(); OutputStream os = sock.getOutputStream()) {
byte[] buf = new byte[128];
int read = is.read(buf);
System.out.println("Client's response: " + new String(buf, 0, read));
System.out.println("Saying hello to client " + os);
os.write("Hello, dear Client".getBytes());
os.flush();
}
}
}
}
}
开发者ID:avast,项目名称:hdfs-shell,代码行数:28,代码来源:SimpleTestServer.java
示例5: startExtension
import org.newsclub.net.unix.AFUNIXServerSocket; //导入依赖的package包/类
/**
* Start extension by communicating with osquery core and starting thrift
* server
*
* @param name
* name of extension
* @param version
* version of extension
* @param sdkVersion
* version of the osquery SDK used to build this extension
* @param minSdkVersion
* minimum version of the osquery SDK that you can use
* @throws IOException
* @throws ExtensionException
*/
public void startExtension(String name, String version, String sdkVersion, String minSdkVersion)
throws IOException, ExtensionException {
ExtensionManager.Client client = new ClientManager(EXTENSION_SOCKET).getClient();
InternalExtensionInfo info = new InternalExtensionInfo(name, version, sdkVersion, minSdkVersion);
try {
ExtensionStatus status = client.registerExtension(info, registry);
if (status.getCode() == 0) {
this.uuid = status.uuid;
Processor<PluginManager> processor = new Processor<PluginManager>(this);
String serverSocketPath = EXTENSION_SOCKET + "." + String.valueOf(uuid);
File socketFile = new File(serverSocketPath);
if (socketFile.exists()) {
socketFile.delete();
}
AFUNIXServerSocket socket = AFUNIXServerSocket.bindOn(new AFUNIXSocketAddress(socketFile));
socketFile.setExecutable(true, false);
socketFile.setWritable(true, false);
socketFile.setReadable(true, false);
TServerSocket transport = new TServerSocket(socket);
TTransportFactory transportFactory = new TTransportFactory();
TProtocolFactory protocolFactory = new TBinaryProtocol.Factory();
TServer server = new TSimpleServer(new Args(transport).processor(processor)
.transportFactory(transportFactory).protocolFactory(protocolFactory));
// Run it
System.out.println("Starting the server...");
server.serve();
} else {
throw new ExtensionException(1, status.getMessage(), uuid);
}
} catch (TException e) {
throw new ExtensionException(1, "Could not connect to socket", uuid);
}
}
开发者ID:melastmohican,项目名称:osquery-java,代码行数:50,代码来源:PluginManager.java
示例6: createUnixSocket
import org.newsclub.net.unix.AFUNIXServerSocket; //导入依赖的package包/类
public static ServerSocket createUnixSocket(File socketFile) throws ContainerException {
try {
maybeUnpackNativeLibraries();
AFUNIXServerSocket server = new AFUNIXServerSocketWrapper();
server.bind(new AFUNIXSocketAddress(socketFile));
return server;
} catch (Exception e) {
throw (ContainerException) new ContainerException(e).setUserMessage("Failed to initialize Unix Socket.").adviseRetry();
}
}
开发者ID:zillabyte,项目名称:motherbrain,代码行数:12,代码来源:UnixSocketHelper.java
示例7: isSupported
import org.newsclub.net.unix.AFUNIXServerSocket; //导入依赖的package包/类
private static boolean isSupported() {
try {
return AFUNIXServerSocket.isSupported();
} catch (LinkageError ignored) {
return false;
}
}
开发者ID:bozaro,项目名称:git-as-svn,代码行数:8,代码来源:SocketConfig.java
示例8: DaemonListener
import org.newsclub.net.unix.AFUNIXServerSocket; //导入依赖的package包/类
/**
* Creates a new DaemonListener and binds it to the given output socket.
*
* @param outSock The path to the output socket for the daemon.
* @throws IOException
*/
public DaemonListener(String outSock) throws IOException {
server = AFUNIXServerSocket.newInstance();
server.bind(new AFUNIXSocketAddress(new File(outSock)));
}
开发者ID:dekarrin,项目名称:phpd,代码行数:11,代码来源:DaemonListener.java
注:本文中的org.newsclub.net.unix.AFUNIXServerSocket类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论