public ApacheUnixSocket() throws IOException { this.inner = AFUNIXSocket.newInstance(); }
@Override public Socket createSocket(HttpParams params) throws IOException { AFUNIXSocket socket = AFUNIXSocket.newInstance(); return socket; }
public ApacheUnixSocket() throws IOException { this.inner = AFUNIXSocket.newInstance(); }
@Override public Socket createSocket() throws IOException { return AFUNIXSocket.newInstance(this); }
public ApacheUnixSocket() throws IOException { this.inner = AFUNIXSocket.newInstance(); }
/** * Creates a new, unbound {@link AFUNIXSocket}. * * This "default" implementation is a bit "lenient" with respect to the specification. * * In particular, we ignore calls to {@link Socket#getTcpNoDelay()} and * {@link Socket#setTcpNoDelay(boolean)}. * * @return A new, unbound socket. * @throws IOException if the operation fails. */ public static AFUNIXSocket newInstance() throws IOException { return newInstance(null); }
/** * Creates a new {@link AFUNIXSocket} and connects it to the given {@link AFUNIXSocketAddress}. * * @param addr The address to connect to. * @return A new, connected socket. * @throws IOException if the operation fails. */ public static AFUNIXSocket connectTo(AFUNIXSocketAddress addr) throws IOException { AFUNIXSocket socket = newInstance(); socket.connect(addr); return socket; }
/** * 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); }
/** * 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); }
/** * Creates a new {@link AFUNIXSocket} and connects it to the given {@link AFUNIXSocketAddress}. * * @param addr The address to connect to. * @return A new, connected socket. */ public static AFUNIXSocket connectTo(AFUNIXSocketAddress addr) throws IOException { AFUNIXSocket socket = newInstance(); socket.connect(addr); return socket; }
UnixPipe(IPCClient ipcClient, HashMap<String, Callback> callbacks, String location) throws IOException { super(ipcClient, callbacks); socket = AFUNIXSocket.newInstance(); socket.connect(new AFUNIXSocketAddress(new File(location))); }
"junixsocket-test.sock"); try (AFUNIXSocket sock = AFUNIXSocket.newInstance()) { try { sock.connect(new AFUNIXSocketAddress(socketFile));
/** * 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); } }
@Override public Socket accept() throws IOException { if (isClosed()) { throw new SocketException("Socket is closed"); } AFUNIXSocket as = AFUNIXSocket.newInstance(); implementation.accept(as.impl); as.addr = boundEndpoint; NativeUnixSocket.setConnected(as); return as; }
/** * Uses the {@link #socketFile} property as the path to initiate a file socket ignoring all parameters of this * method. * * @param host Unsupported, will be ignored * @param port Unsupported, will be ignored * * @return unix socket * * @throws IOException if the file system location cannot be URL decoded */ @Override public Socket createSocket(final String host, final int port) throws IOException { final File file; if (socketFile == null) { throw new IOException("socketFile (specified in org.ldaptive.ldapi.socketFile" + " or passed through factory constructor) MUST be specified to call this method."); } file = new File(URLDecoder.decode(socketFile, "UTF-8")); final AFUNIXSocketAddress localAddress = new AFUNIXSocketAddress(file); final AFUNIXSocket sock = AFUNIXSocket.newInstance(); sock.connect(localAddress); return sock; }
@Override public Socket accept() throws IOException { if (isClosed()) { throw new SocketException("Socket is closed"); } AFUNIXSocket as = AFUNIXSocket.newInstance(); implementation.accept(as.impl); as.addr = boundEndpoint; NativeUnixSocket.setConnected(as); return as; }
/** * 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 ProxyPump(incomingSocket, outgoingSocket); } catch (IOException ignored) { } } }); acceptThread.setDaemon(true); acceptThread.setName("tcp-unix-proxy-accept-thread"); acceptThread.start(); return (InetSocketAddress) listenSocket.getLocalSocketAddress(); }