@Override public void bind(SocketAddress endpoint, int backlog) throws IOException { if (isClosed()) { throw new SocketException("Socket is closed"); } if (isBound()) { throw new SocketException("Already bound"); } if (!(endpoint instanceof AFUNIXSocketAddress)) { throw new IOException("Can only bind to endpoints of type " + AFUNIXSocketAddress.class .getName()); } implementation.bind(backlog, endpoint); boundEndpoint = (AFUNIXSocketAddress) endpoint; }
@Override public void bind(SocketAddress endpoint, int backlog) throws IOException { if (isClosed()) { throw new SocketException("Socket is closed"); } if (isBound()) { throw new SocketException("Already bound"); } if (!(endpoint instanceof AFUNIXSocketAddress)) { throw new IOException("Can only bind to endpoints of type " + AFUNIXSocketAddress.class.getName()); } implementation.bind(backlog, endpoint); boundEndpoint = (AFUNIXSocketAddress) endpoint; }
@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; }
@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 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; }
@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 } }