当前位置: 首页>>代码示例>>Java>>正文


Java AFUNIXSocketAddress类代码示例

本文整理汇总了Java中org.newsclub.net.unix.AFUNIXSocketAddress的典型用法代码示例。如果您正苦于以下问题:Java AFUNIXSocketAddress类的具体用法?Java AFUNIXSocketAddress怎么用?Java AFUNIXSocketAddress使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AFUNIXSocketAddress类属于org.newsclub.net.unix包,在下文中一共展示了AFUNIXSocketAddress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import org.newsclub.net.unix.AFUNIXSocketAddress; //导入依赖的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: start

import org.newsclub.net.unix.AFUNIXSocketAddress; //导入依赖的package包/类
/**
 * Start the proxy
 * @return the proxy's listening socket address
 * @throws IOException on socket binding failure
 */
public InetSocketAddress start() throws IOException {

    listenSocket = new ServerSocket();
    listenSocket.bind(new InetSocketAddress(listenHostname, listenPort));

    logger.debug("Listening on {} and proxying to {}", listenSocket.getLocalSocketAddress(), unixSocketFile.getAbsolutePath());

    acceptThread = new Thread(() -> {
        while (running) {
            try {
                Socket incomingSocket = listenSocket.accept();
                logger.debug("Accepting incoming connection from {}", incomingSocket.getRemoteSocketAddress());

                AFUNIXSocket outgoingSocket = AFUNIXSocket.newInstance();
                outgoingSocket.connect(new AFUNIXSocketAddress(unixSocketFile));

                new ProxyThread(incomingSocket, outgoingSocket);
            } catch (IOException ignored) {
            }
        }
    });
    acceptThread.start();

    return (InetSocketAddress) listenSocket.getLocalSocketAddress();
}
 
开发者ID:rnorth,项目名称:tcp-unix-socket-proxy,代码行数:31,代码来源:TcpToUnixSocketProxy.java

示例3: producer

import org.newsclub.net.unix.AFUNIXSocketAddress; //导入依赖的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

示例4: connectSocket

import org.newsclub.net.unix.AFUNIXSocketAddress; //导入依赖的package包/类
@Override
  public Socket connectSocket(Socket socket, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
    int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
//    int soTimeout = HttpConnectionParams.getSoTimeout(params)

    try {
//      socket.setSoTimeout(soTimeout)
      socket.connect(new AFUNIXSocketAddress(socketFile), connTimeout);
//      socket.connect(new AFUNIXSocketAddress(socketFile))
    }
    catch (SocketTimeoutException e) {
      throw new ConnectTimeoutException("Connect to '" + socketFile + "' timed out");
    }

    return socket;
  }
 
开发者ID:gesellix,项目名称:unix-socket-factory,代码行数:17,代码来源:UnixSocketFactory.java

示例5: create

import org.newsclub.net.unix.AFUNIXSocketAddress; //导入依赖的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

示例6: getSocket

import org.newsclub.net.unix.AFUNIXSocketAddress; //导入依赖的package包/类
/**
 * Create a plain {@link Socket} to docker API endpoint
 */
public Socket getSocket() throws IOException {
    try {
        final URI uri = new URI(dockerHost.getUri());
        if ("unix".equals(uri.getScheme())) {
            final AFUNIXSocketAddress unix = new AFUNIXSocketAddress(new File("/var/run/docker.sock"));
            final Socket socket = AFUNIXSocket.newInstance();
            socket.connect(unix);
            return socket;
        }

        final SSLConfig sslConfig = toSSlConfig(dockerHost.getCredentialsId());
        if (sslConfig != null) {
            return sslConfig.getSSLContext().getSocketFactory().createSocket(uri.getHost(), uri.getPort());
        } else {
            return new Socket(uri.getHost(), uri.getPort());
        }
    } catch (Exception e) {
        throw new IOException("Failed to create a Socker for docker URI " + dockerHost.getUri(), e);
    }
}
 
开发者ID:jenkinsci,项目名称:docker-plugin,代码行数:24,代码来源:DockerAPI.java

示例7: send

import org.newsclub.net.unix.AFUNIXSocketAddress; //导入依赖的package包/类
/**
 * Sends input to the phpd input socket.
 * 
 * @param input The messages to send.
 * @throws IOException 
 */
private void send(String... input) throws IOException {
	StringBuilder buffer = new StringBuilder();
	for (String msg : input) {
		buffer.append(msg.length());
		buffer.append('\n');
		buffer.append(msg);
	}
	File socketFile = new File(getConfig("PARTE_PHPD_IN_SOCKET_DOMAIN"));
	AFUNIXSocket sock = AFUNIXSocket.newInstance();
	sock.connect(new AFUNIXSocketAddress(socketFile));
	PrintWriter pw = new PrintWriter(sock.getOutputStream());
	pw.write(buffer.toString());
	pw.flush();
	pw.close();
	sock.close();
}
 
开发者ID:dekarrin,项目名称:phpd,代码行数:23,代码来源:Daemon.java

示例8: main

import org.newsclub.net.unix.AFUNIXSocketAddress; //导入依赖的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

示例9: ClientManager

import org.newsclub.net.unix.AFUNIXSocketAddress; //导入依赖的package包/类
/**
 * Constructor with given socket path
 * @param socketPath
 * @throws IOException
 */
public ClientManager(String socketPath) throws IOException  {
	this.socketPath = socketPath;
	AFUNIXSocket socket = AFUNIXSocket.connectTo(new AFUNIXSocketAddress(new File(socketPath)));
	this.transport = new TIOStreamTransport(socket.getInputStream(), socket.getOutputStream());
	this.protocol = new TBinaryProtocol(transport);
}
 
开发者ID:melastmohican,项目名称:osquery-java,代码行数:12,代码来源:ClientManager.java

示例10: startExtension

import org.newsclub.net.unix.AFUNIXSocketAddress; //导入依赖的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

示例11: connectSocket

import org.newsclub.net.unix.AFUNIXSocketAddress; //导入依赖的package包/类
@Override
public Socket connectSocket(final int connectTimeout,
                            final Socket socket,
                            final HttpHost host,
                            final InetSocketAddress remoteAddress,
                            final InetSocketAddress localAddress,
                            final HttpContext context) throws IOException {
  try {
    socket.connect(new AFUNIXSocketAddress(socketFile), connectTimeout);
  } catch (SocketTimeoutException e) {
    throw new ConnectTimeoutException(e, null, remoteAddress.getAddress());
  }

  return socket;
}
 
开发者ID:flyaruu,项目名称:tasman,代码行数:16,代码来源:UnixSocketFactory.java

示例12: connect

import org.newsclub.net.unix.AFUNIXSocketAddress; //导入依赖的package包/类
@Override
public void connect(SocketAddress endpoint, int timeout) throws IOException {
    InetAddress address = ((InetSocketAddress) endpoint).getAddress();
    String socketPath = decodeHostname(address);

    System.out.println("connect via '" + socketPath + "'...");
    File socketFile = new File(socketPath);

    socket = AFUNIXSocket.newInstance();
    socket.connect(new AFUNIXSocketAddress(socketFile), timeout);
    socket.setSoTimeout(timeout);
}
 
开发者ID:shekhargulati,项目名称:rx-okhttp,代码行数:13,代码来源:OkHttpUnixSocketRxHttpClient.java

示例13: createUnixSocket

import org.newsclub.net.unix.AFUNIXSocketAddress; //导入依赖的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

示例14: connectSocket

import org.newsclub.net.unix.AFUNIXSocketAddress; //导入依赖的package包/类
@Override
public Socket connectSocket(final int connectTimeout, final Socket socket, final HttpHost host,
        final InetSocketAddress remoteAddress, final InetSocketAddress localAddress, final HttpContext context)
        throws IOException {
    try {
        socket.connect(new AFUNIXSocketAddress(socketFile), connectTimeout);
    } catch (SocketTimeoutException e) {
        throw new ConnectTimeoutException(e, null, remoteAddress.getAddress());
    }

    return socket;
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:13,代码来源:UnixConnectionSocketFactory.java

示例15: bind

import org.newsclub.net.unix.AFUNIXSocketAddress; //导入依赖的package包/类
public void bind(SocketAddress endpoint, int backlog) throws IOException {
  super.bind(endpoint, backlog);
  _endpoint = (AFUNIXSocketAddress) endpoint;
}
 
开发者ID:zillabyte,项目名称:motherbrain,代码行数:5,代码来源:UnixSocketHelper.java


注:本文中的org.newsclub.net.unix.AFUNIXSocketAddress类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。