/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* An implementation of ServerSocketChannels
*/
class ServerSocketChannelImpl
extends ServerSocketChannel
implements SelChImpl
{
// Used to make native close and configure calls
// Our file descriptor
// even after the value in the file descriptor object has been set to -1
private int fdVal;
// ID of native thread currently blocked in this channel, for signalling
// Lock held by thread currently blocked in this channel
// Lock held by any thread that modifies the state fields declared below
// DO NOT invoke a blocking I/O operation while holding this lock!
// -- The following fields are protected by stateLock
// Channel state, increases monotonically
// Binding
// set true when exclusive binding is on and SO_REUSEADDR is emulated
private boolean isReuseAddress;
// Our socket adaptor, if any
// -- End of fields protected by stateLock
super(sp);
}
boolean bound)
throws IOException
{
super(sp);
if (bound)
}
synchronized (stateLock) {
return socket;
}
}
synchronized (stateLock) {
if (!isOpen())
throw new ClosedChannelException();
}
}
throws IOException
{
throw new NullPointerException();
synchronized (stateLock) {
if (!isOpen())
throw new ClosedChannelException();
{
// SO_REUSEADDR emulated when using exclusive bind
} else {
// no options that require special handling
}
return this;
}
}
@SuppressWarnings("unchecked")
throws IOException
{
throw new NullPointerException();
synchronized (stateLock) {
if (!isOpen())
throw new ClosedChannelException();
{
// SO_REUSEADDR emulated when using exclusive bind
}
// no options that require special handling
}
}
private static class DefaultOptionsHolder {
}
}
return DefaultOptionsHolder.defaultOptions;
}
public boolean isBound() {
synchronized (stateLock) {
return localAddress != null;
}
}
synchronized (stateLock) {
return localAddress;
}
}
synchronized (lock) {
if (!isOpen())
throw new ClosedChannelException();
if (isBound())
throw new AlreadyBoundException();
synchronized (stateLock) {
}
}
return this;
}
synchronized (lock) {
if (!isOpen())
throw new ClosedChannelException();
if (!isBound())
throw new NotYetBoundException();
int n = 0;
try {
begin();
if (!isOpen())
return null;
for (;;) {
continue;
break;
}
} finally {
thread = 0;
end(n > 0);
}
if (n < 1)
return null;
try {
} catch (SecurityException x) {
throw x;
}
}
return sc;
}
}
}
synchronized (stateLock) {
if (th != 0)
if (!isRegistered())
kill();
}
}
synchronized (stateLock) {
return;
if (state == ST_UNINITIALIZED) {
return;
}
assert !isOpen() && !isRegistered();
}
}
/**
* Translates native poll revent set into a ready operation set
*/
int newOps = initialOps;
// This should only happen if this channel is pre-closed while a
// selection operation is in progress
// ## Throw an error if this channel has not been pre-closed
return false;
}
}
}
}
}
/**
* Translates an interest operation set into a native poll event set
*/
int newOps = 0;
// Translate ops
// Place ops into pollfd array
}
return fd;
}
public int getFDVal() {
return fdVal;
}
if (!isOpen()) {
} else {
synchronized (stateLock) {
} else {
}
}
}
}
// -- Native methods --
// Accepts a new connection, setting the given file descriptor to refer to
// the new socket and setting isaa[0] to the socket's remote address.
// Returns 1 on success, or IOStatus.UNAVAILABLE (if non-blocking and no
// connections are pending) or IOStatus.INTERRUPTED.
//
throws IOException;
private static native void initIDs();
static {
initIDs();
nd = new SocketDispatcher();
}
}