本文整理汇总了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();
}
示例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: 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);
}
示例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);
}
示例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;
}
}
示例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;
}
示例8: createSocket
import org.newsclub.net.unix.AFUNIXSocket; //导入依赖的package包/类
@Override
public Socket createSocket(HttpContext context) throws IOException {
AFUNIXSocket socket = AFUNIXSocket.newInstance();
return socket;
}
示例9: UnixSocketFactory
import org.newsclub.net.unix.AFUNIXSocket; //导入依赖的package包/类
public UnixSocketFactory() {
if (!AFUNIXSocket.isSupported()) {
throw new UnsupportedOperationException("AFUNIXSocket.isSupported() == false");
}
}
示例10: createSocket
import org.newsclub.net.unix.AFUNIXSocket; //导入依赖的package包/类
@Override
public Socket createSocket(HttpParams params) throws IOException {
AFUNIXSocket socket = AFUNIXSocket.newInstance();
return socket;
}
示例11: ApacheUnixSocket
import org.newsclub.net.unix.AFUNIXSocket; //导入依赖的package包/类
public ApacheUnixSocket() throws IOException {
this.inner = AFUNIXSocket.newInstance();
}
示例12: read
import org.newsclub.net.unix.AFUNIXSocket; //导入依赖的package包/类
@Override
public int read(byte[] buffer) throws IOException {
return ((AFUNIXSocket) this.socket).getInputStream().read(buffer);
}
示例13: write
import org.newsclub.net.unix.AFUNIXSocket; //导入依赖的package包/类
@Override
public void write(byte[] buffer) throws IOException {
((AFUNIXSocket) this.socket).getOutputStream().write(buffer);
}
示例14: detach
import org.newsclub.net.unix.AFUNIXSocket; //导入依赖的package包/类
@Override
public void detach() throws IOException {
((AFUNIXSocket) this.socket).close();
}
示例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);
}