本文整理汇总了Java中java.nio.channels.AlreadyBoundException类的典型用法代码示例。如果您正苦于以下问题:Java AlreadyBoundException类的具体用法?Java AlreadyBoundException怎么用?Java AlreadyBoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AlreadyBoundException类属于java.nio.channels包,在下文中一共展示了AlreadyBoundException类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bind
import java.nio.channels.AlreadyBoundException; //导入依赖的package包/类
/** @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;
}
示例2: bind
import java.nio.channels.AlreadyBoundException; //导入依赖的package包/类
/** @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;
}
示例3: bind
import java.nio.channels.AlreadyBoundException; //导入依赖的package包/类
/** @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;
}
示例4: throwAlreadyBoundException
import java.nio.channels.AlreadyBoundException; //导入依赖的package包/类
static boolean throwAlreadyBoundException() throws IOException {
throw new AlreadyBoundException();
}