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 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; }
@Override public void run() { try { if (boundEndpoint != null) { NativeUnixSocket.unlink(boundEndpoint.getSocketFile()); } } catch (IOException e) { // ignore } } };
@Override public String toString() { if (!isBound()) { return "AFUNIXServerSocket[unbound]"; } return "AFUNIXServerSocket[" + boundEndpoint.getSocketFile() + "]"; }
@Override public String toString() { if (!isBound()) { return "AFUNIXServerSocket[unbound]"; } return "AFUNIXServerSocket[" + boundEndpoint.getSocketFile() + "]"; }
@Override public void run() { try { if (boundEndpoint != null) { NativeUnixSocket.unlink(boundEndpoint.getSocketFile()); } } catch (IOException e) { // ignore } } };
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(); }
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 (isConnected()) { return "AFUNIXSocket[fd=" + impl.getFD() + ";path=" + addr.getSocketFile() + "]"; } return "AFUNIXSocket[unconnected]"; }
@Override public String toString() { if (isConnected()) { return "AFUNIXSocket[fd=" + impl.getFD() + ";path=" + addr.getSocketFile() + "]"; } return "AFUNIXSocket[unconnected]"; }
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 Socket createSocket(String host, int port) throws IOException, UnknownHostException { if (!isHostnameSupported(host)) { throw new UnknownHostException(); } if (port < 0) { throw new IllegalArgumentException("Illegal port"); } AFUNIXSocketAddress socketAddress = addressFromHost(host, port); String socketFile = socketAddress.getSocketFile(); if (socketFile == null || socketFile.isEmpty()) { throw new UnknownHostException("Illegal socketFile"); } File file = new File(socketFile); if (!file.exists()) { throw new UnknownHostException("Socketfile does not exist"); } return AFUNIXSocket.connectTo(socketAddress); }
@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; }
@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; }
@Override public void close() throws IOException { if (isClosed()) { return; } super.close(); implementation.close(); if (boundEndpoint != null) { NativeUnixSocket.unlink(boundEndpoint.getSocketFile()); } try { Runtime.getRuntime().removeShutdownHook(shutdownThread); } catch (IllegalStateException e) { // ignore } }
@Override public void close() throws IOException { if (isClosed()) { return; } super.close(); implementation.close(); if (boundEndpoint != null) { NativeUnixSocket.unlink(boundEndpoint.getSocketFile()); } try { Runtime.getRuntime().removeShutdownHook(shutdownThread); } catch (IllegalStateException e) { // ignore } }
@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; }