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


Java AFUNIXSocket类代码示例

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


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

示例1: start

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

示例2: getSocket

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

示例3: send

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

示例4: ClientManager

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

示例5: connect

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

示例6: assertAvailability

import org.newsclub.net.unix.AFUNIXSocket; //导入依赖的package包/类
/**
 * Asserts the availability of this virtual machine implementation. If the Unix socket library is missing or
 * if this VM does not support Unix socket communication, a {@link Throwable} is thrown.
 *
 * @return This virtual machine type.
 * @throws Throwable If this VM does not support POSIX sockets or is not running on a HotSpot VM.
 */
public static Class<?> assertAvailability() throws Throwable {
    if (!AFUNIXSocket.isSupported()) {
        throw new IllegalStateException("POSIX sockets are not supported on the current system");
    } else if (!System.getProperty("java.vm.name").toLowerCase(Locale.US).contains("hotspot")) {
        throw new IllegalStateException("Cannot apply attachment on non-Hotspot compatible VM");
    } else {
        return OnUnix.class;
    }
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:17,代码来源:VirtualMachine.java

示例7: UnixSocketRule

import org.newsclub.net.unix.AFUNIXSocket; //导入依赖的package包/类
public UnixSocketRule() {
    boolean enabled;
    try {
        Class.forName(AFUNIXSocket.class.getName(), true, UnixSocketRule.class.getClassLoader());
        enabled = true;
    } catch (Throwable ignored) {
        enabled = false;
    }
    this.enabled = enabled;
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:11,代码来源:UnixSocketRule.java

示例8: createSocket

import org.newsclub.net.unix.AFUNIXSocket; //导入依赖的package包/类
@Override
public Socket createSocket(HttpContext context) throws IOException {
	AFUNIXSocket socket = AFUNIXSocket.newInstance();
	return socket;
}
 
开发者ID:flyaruu,项目名称:tasman,代码行数:6,代码来源:UnixSocketFactory.java

示例9: UnixSocketFactory

import org.newsclub.net.unix.AFUNIXSocket; //导入依赖的package包/类
public UnixSocketFactory() {
    if (!AFUNIXSocket.isSupported()) {
        throw new UnsupportedOperationException("AFUNIXSocket.isSupported() == false");
    }
}
 
开发者ID:shekhargulati,项目名称:rx-okhttp,代码行数:6,代码来源:OkHttpUnixSocketRxHttpClient.java

示例10: createSocket

import org.newsclub.net.unix.AFUNIXSocket; //导入依赖的package包/类
@Override
public Socket createSocket(HttpParams params) throws IOException {
  AFUNIXSocket socket = AFUNIXSocket.newInstance();
  return socket;
}
 
开发者ID:gesellix,项目名称:unix-socket-factory,代码行数:6,代码来源:UnixSocketFactory.java

示例11: ApacheUnixSocket

import org.newsclub.net.unix.AFUNIXSocket; //导入依赖的package包/类
public ApacheUnixSocket() throws IOException {
    this.inner = AFUNIXSocket.newInstance();
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:4,代码来源:ApacheUnixSocket.java

示例12: read

import org.newsclub.net.unix.AFUNIXSocket; //导入依赖的package包/类
@Override
public int read(byte[] buffer) throws IOException {
    return ((AFUNIXSocket) this.socket).getInputStream().read(buffer);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:5,代码来源:VirtualMachine.java

示例13: write

import org.newsclub.net.unix.AFUNIXSocket; //导入依赖的package包/类
@Override
public void write(byte[] buffer) throws IOException {
    ((AFUNIXSocket) this.socket).getOutputStream().write(buffer);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:5,代码来源:VirtualMachine.java

示例14: detach

import org.newsclub.net.unix.AFUNIXSocket; //导入依赖的package包/类
@Override
public void detach() throws IOException {
    ((AFUNIXSocket) this.socket).close();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:5,代码来源:VirtualMachine.java

示例15: attach

import org.newsclub.net.unix.AFUNIXSocket; //导入依赖的package包/类
/**
 * Attaches to the supplied VM process.
 *
 * @param processId The process id of the target VM.
 * @return An appropriate virtual machine implementation.
 * @throws IOException If an I/O exception occurs.
 */
public static VirtualMachine attach(String processId) throws IOException {
    return new OnUnix(processId, AFUNIXSocket.newInstance(), DEFAULT_ATTEMPTS, DEFAULT_PAUSE, DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:11,代码来源:VirtualMachine.java


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