本文整理汇总了Java中org.newsclub.net.unix.AFUNIXSocket.newInstance方法的典型用法代码示例。如果您正苦于以下问题:Java AFUNIXSocket.newInstance方法的具体用法?Java AFUNIXSocket.newInstance怎么用?Java AFUNIXSocket.newInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.newsclub.net.unix.AFUNIXSocket
的用法示例。
在下文中一共展示了AFUNIXSocket.newInstance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
}
}
示例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();
}
示例4: 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);
}
示例5: createSocket
import org.newsclub.net.unix.AFUNIXSocket; //导入方法依赖的package包/类
@Override
public Socket createSocket(HttpContext context) throws IOException {
AFUNIXSocket socket = AFUNIXSocket.newInstance();
return socket;
}
示例6: createSocket
import org.newsclub.net.unix.AFUNIXSocket; //导入方法依赖的package包/类
@Override
public Socket createSocket(HttpParams params) throws IOException {
AFUNIXSocket socket = AFUNIXSocket.newInstance();
return socket;
}
示例7: ApacheUnixSocket
import org.newsclub.net.unix.AFUNIXSocket; //导入方法依赖的package包/类
public ApacheUnixSocket() throws IOException {
this.inner = AFUNIXSocket.newInstance();
}
示例8: 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);
}