@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; } }
@Override protected void connect(SocketAddress addr, int timeout) throws IOException { if (!(addr instanceof AFUNIXSocketAddress)) { throw new SocketException("Cannot bind to this type of address: " + addr.getClass()); } final AFUNIXSocketAddress socketAddress = (AFUNIXSocketAddress) addr; socketFile = socketAddress.getSocketFile(); NativeUnixSocket.connect(socketFile, fd); this.address = socketAddress.getAddress(); this.port = socketAddress.getPort(); this.localport = 0; this.connected = true; }
protected void bind(int backlog, SocketAddress addr) throws IOException { if (!(addr instanceof AFUNIXSocketAddress)) { throw new SocketException("Cannot bind to this type of address: " + addr.getClass()); } final AFUNIXSocketAddress socketAddress = (AFUNIXSocketAddress) addr; socketFile = socketAddress.getSocketFile(); NativeUnixSocket.bind(socketFile, fd, backlog); bound = true; this.localport = socketAddress.getPort(); }
@Override public void run() { try { if (boundEndpoint != null) { NativeUnixSocket.unlink(boundEndpoint.getSocketFile()); } } catch (IOException e) { // ignore } } };
@Override public String toString() { return getClass().getName() + "[host=" + getHostName() + ";port=" + getPort() + ";file=" + socketFile + "]"; } }
protected void bind(int backlog, SocketAddress addr) throws IOException { if (!(addr instanceof AFUNIXSocketAddress)) { throw new SocketException("Cannot bind to this type of address: " + addr.getClass()); } final AFUNIXSocketAddress socketAddress = (AFUNIXSocketAddress) addr; socketFile = socketAddress.getSocketFile(); NativeUnixSocket.bind(socketFile, fd, backlog); bound = true; this.localport = socketAddress.getPort(); }
@Override public String toString() { if (!isBound()) { return "AFUNIXServerSocket[unbound]"; } return "AFUNIXServerSocket[" + boundEndpoint.getSocketFile() + "]"; }
@Override public String toString() { return getClass().getName() + "[host=" + getHostName() + ";port=" + getPort() + ";file=" + socketFile + "]"; } }
@Override protected AFUNIXSocketAddress addressFromHost(String host, int port) throws IOException { return new AFUNIXSocketAddress(socketFile, port); } }
@Override protected void connect(SocketAddress addr, int timeout) throws IOException { if (!(addr instanceof AFUNIXSocketAddress)) { throw new SocketException("Cannot bind to this type of address: " + addr.getClass()); } final AFUNIXSocketAddress socketAddress = (AFUNIXSocketAddress) addr; socketFile = socketAddress.getSocketFile(); NativeUnixSocket.connect(socketFile, fd); this.address = socketAddress.getAddress(); this.port = socketAddress.getPort(); this.localport = 0; this.connected = true; }
protected void bind(int backlog, SocketAddress addr) throws IOException { if (!(addr instanceof AFUNIXSocketAddress)) { throw new SocketException("Cannot bind to this type of address: " + addr.getClass()); } final AFUNIXSocketAddress socketAddress = (AFUNIXSocketAddress) addr; socketFile = socketAddress.getSocketFile(); NativeUnixSocket.bind(socketFile, fd, backlog); bound = true; this.localport = socketAddress.getPort(); }
@Override public String toString() { if (!isBound()) { return "AFUNIXServerSocket[unbound]"; } return "AFUNIXServerSocket[" + boundEndpoint.getSocketFile() + "]"; }
@Override protected AFUNIXSocketAddress addressFromHost(String host, int port) throws IOException { String path = System.getProperty(PROP_SOCKET_DEFAULT); if (path == null || path.isEmpty()) { throw new IllegalStateException("Property not configured: " + PROP_SOCKET_DEFAULT); } File socketFile = new File(path); return new AFUNIXSocketAddress(socketFile, port); } }
@Override protected void connect(SocketAddress addr, int timeout) throws IOException { if (!(addr instanceof AFUNIXSocketAddress)) { throw new SocketException("Cannot bind to this type of address: " + addr.getClass()); } final AFUNIXSocketAddress socketAddress = (AFUNIXSocketAddress) addr; socketFile = socketAddress.getSocketFile(); NativeUnixSocket.connect(socketFile, fd); this.address = socketAddress.getAddress(); this.port = socketAddress.getPort(); this.localport = 0; this.connected = true; }
protected void bind(int backlog, SocketAddress addr) throws IOException { if (!(addr instanceof AFUNIXSocketAddress)) { throw new SocketException("Cannot bind to this type of address: " + addr.getClass()); } final AFUNIXSocketAddress socketAddress = (AFUNIXSocketAddress) addr; socketFile = socketAddress.getSocketFile(); NativeUnixSocket.bind(socketFile, fd, backlog); validFdOrException(); bound = true; this.localport = socketAddress.getPort(); }
@Override public void run() { try { if (boundEndpoint != null) { NativeUnixSocket.unlink(boundEndpoint.getSocketFile()); } } catch (IOException e) { // ignore } } };
@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; } }
@Override protected void connect(SocketAddress addr, int timeout) throws IOException { if (!(addr instanceof AFUNIXSocketAddress)) { throw new SocketException("Cannot bind to this type of address: " + addr.getClass()); } final AFUNIXSocketAddress socketAddress = (AFUNIXSocketAddress) addr; socketFile = socketAddress.getSocketFile(); NativeUnixSocket.connect(validateSocketFile(socketFile), fd); validFdOrException(); this.address = socketAddress.getAddress(); this.port = socketAddress.getPort(); this.localport = 0; this.connected = true; }
@Override public String toString() { if (isConnected()) { return "AFUNIXSocket[fd=" + impl.getFD() + ";path=" + addr.getSocketFile() + "]"; } return "AFUNIXSocket[unconnected]"; }
public class DevLogServer { public static void main(String[] args) throws IOException { final File socketFile = new File("/dev/log"); AFUNIXServerSocket server = AFUNIXServerSocket.newInstance(); try { server.bind(new AFUNIXSocketAddress(socketFile)); } catch (Exception e) { throw e; } } }