/** @hide Until ready for a public API change */ @Override synchronized public DatagramChannel bind(SocketAddress local) throws IOException { checkOpen(); if (isBound) { throw new AlreadyBoundException(); } if (local == null) { local = new InetSocketAddress(Inet4Address.ANY, 0); } else if (!(local instanceof InetSocketAddress)) { throw new UnsupportedAddressTypeException(); } InetSocketAddress localAddress = (InetSocketAddress) local; IoBridge.bind(fd, localAddress.getAddress(), localAddress.getPort()); onBind(true /* updateSocketState */); return this; }
/** @hide Until ready for a public API change */ @Override synchronized public final SocketChannel bind(SocketAddress local) throws IOException { if (!isOpen()) { throw new ClosedChannelException(); } if (isBound) { throw new AlreadyBoundException(); } if (local == null) { local = new InetSocketAddress(Inet4Address.ANY, 0); } else if (!(local instanceof InetSocketAddress)) { throw new UnsupportedAddressTypeException(); } InetSocketAddress localAddress = (InetSocketAddress) local; IoBridge.bind(fd, localAddress.getAddress(), localAddress.getPort()); onBind(true /* updateSocketState */); return this; }
/** @hide Until ready for a public API change */ @Override public final ServerSocketChannel bind(SocketAddress localAddr, int backlog) throws IOException { if (!isOpen()) { throw new ClosedChannelException(); } if (socket.isBound()) { throw new AlreadyBoundException(); } if (localAddr != null && !(localAddr instanceof InetSocketAddress)) { throw new UnsupportedAddressTypeException(); } socket.bind(localAddr, backlog); return this; }
static boolean throwAlreadyBoundException() throws IOException { throw new AlreadyBoundException(); }