下面列出了java.nio.channels.AlreadyBoundException 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public DatagramChannel bind(SocketAddress local) throws IOException {
readLock.lock();
try {
writeLock.lock();
try {
synchronized (stateLock) {
ensureOpen();
if (localAddress != null)
throw new AlreadyBoundException();
bindInternal(local);
}
} finally {
writeLock.unlock();
}
} finally {
readLock.unlock();
}
return this;
}
@Override
public ServerSocketChannel bind(SocketAddress local, int backlog) throws IOException {
synchronized (stateLock) {
ensureOpen();
if (localAddress != null)
throw new AlreadyBoundException();
InetSocketAddress isa = (local == null)
? new InetSocketAddress(0)
: Net.checkAddress(local);
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkListen(isa.getPort());
NetHooks.beforeTcpBind(fd, isa.getAddress(), isa.getPort());
Net.bind(fd, isa.getAddress(), isa.getPort());
Net.listen(fd, backlog < 1 ? 50 : backlog);
localAddress = Net.localAddress(fd);
}
return this;
}
@Override
public SocketChannel bind(SocketAddress local) throws IOException {
readLock.lock();
try {
writeLock.lock();
try {
synchronized (stateLock) {
ensureOpen();
if (state == ST_CONNECTIONPENDING)
throw new ConnectionPendingException();
if (localAddress != null)
throw new AlreadyBoundException();
InetSocketAddress isa = (local == null) ?
new InetSocketAddress(0) : Net.checkAddress(local);
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkListen(isa.getPort());
}
NetHooks.beforeTcpBind(fd, isa.getAddress(), isa.getPort());
Net.bind(fd, isa.getAddress(), isa.getPort());
localAddress = Net.localAddress(fd);
}
} finally {
writeLock.unlock();
}
} finally {
readLock.unlock();
}
return this;
}
static boolean throwAlreadyBoundException() throws IOException {
throw new AlreadyBoundException();
}
static boolean throwAlreadyBoundException() throws IOException {
throw new AlreadyBoundException();
}
static boolean throwAlreadyBoundException() throws IOException {
throw new AlreadyBoundException();
}
static boolean throwAlreadyBoundException() throws IOException {
throw new AlreadyBoundException();
}
static boolean throwAlreadyBoundException() throws IOException {
throw new AlreadyBoundException();
}
static boolean throwAlreadyBoundException() throws IOException {
throw new AlreadyBoundException();
}
static boolean throwAlreadyBoundException() throws IOException {
throw new AlreadyBoundException();
}
static boolean throwAlreadyBoundException() throws IOException {
throw new AlreadyBoundException();
}
static boolean throwAlreadyBoundException() throws IOException {
throw new AlreadyBoundException();
}
static boolean throwAlreadyBoundException() throws IOException {
throw new AlreadyBoundException();
}
static boolean throwAlreadyBoundException() throws IOException {
throw new AlreadyBoundException();
}
static boolean throwAlreadyBoundException() throws IOException {
throw new AlreadyBoundException();
}
static boolean throwAlreadyBoundException() throws IOException {
throw new AlreadyBoundException();
}