|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.sgs.nio.channels.AsynchronousChannel
com.sun.sgs.nio.channels.AsynchronousServerSocketChannel
com.sun.sgs.impl.nio.AsyncServerSocketChannelImpl
final class AsyncServerSocketChannelImpl
An implementation of AsynchronousServerSocketChannel.
Most interesting methods are delegated to the AsyncKey
returned by this channel's channel group.
| Field Summary | |
|---|---|
(package private) ServerSocketChannel |
channel
The underlying ServerSocketChannel. |
(package private) AsyncGroupImpl |
group
The channel group. |
(package private) AsyncKey |
key
The AsyncKey for the underlying channel. |
| Constructor Summary | |
|---|---|
AsyncServerSocketChannelImpl(AsyncGroupImpl group)
Creates a new instance registered with the given channel group. |
|
| Method Summary | ||
|---|---|---|
|
accept(A attachment,
CompletionHandler<AsynchronousSocketChannel,? super A> handler)
Accepts a connection. |
|
AsyncServerSocketChannelImpl |
bind(SocketAddress local,
int backlog)
Binds the channel's socket to a local address and configures the socket to listen for connections. |
|
void |
close()
Closes this channel. |
|
SocketAddress |
getLocalAddress()
Returns the socket address that this channel's socket is bound to, or null if the socket is not bound. |
|
Object |
getOption(SocketOption name)
Returns the value of a socket option. |
|
boolean |
isAcceptPending()
Tells whether or not an accept is pending for this channel. |
|
boolean |
isOpen()
|
|
Set<SocketOption> |
options()
Returns a set of the socket options supported by this channel. |
|
AsyncServerSocketChannelImpl |
setOption(SocketOption name,
Object value)
Sets the value of a socket option. |
|
String |
toString()
|
|
| Methods inherited from class com.sun.sgs.nio.channels.AsynchronousServerSocketChannel |
|---|
accept, bind, open, open |
| Methods inherited from class com.sun.sgs.nio.channels.AsynchronousChannel |
|---|
provider |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
final AsyncGroupImpl group
final ServerSocketChannel channel
ServerSocketChannel.
final AsyncKey key
AsyncKey for the underlying channel.
| Constructor Detail |
|---|
AsyncServerSocketChannelImpl(AsyncGroupImpl group)
throws IOException
group - the channel group
IOException - if an I/O error occurs| Method Detail |
|---|
public String toString()
toString in class Objectpublic boolean isOpen()
public void close()
throws IOException
Any outstanding asynchronous operations upon this channel will
complete by throwing ExecutionException with cause
AsynchronousCloseException.
This method otherwise behaves exactly as specified by the
Channel interface.
close in interface Closeableclose in interface Channelclose in class AsynchronousChannelIOException - if an I/O error occurs
public AsyncServerSocketChannelImpl bind(SocketAddress local,
int backlog)
throws IOException
This method is used to establish an association between the socket and a local address. Once an association is established then the socket remains bound until the associated channel is closed. An attempt to bind a socket that is already bound throws AlreadyBoundException. If the local parameter has the value null then the socket address is assigned automatically.
The backlog parameter is the maximum number of pending connections on the socket. Its exact semantics are implementation specific. An implementation may impose an implementation specific maximum length or may choose to ignore the parameter. If the backlog parameter has the value 0, or a negative value, then an implementation specific default is used.
bind in class AsynchronousServerSocketChannellocal - the local address to bind the socket, or null
to bind to an automatically assigned socket addressbacklog - the maximum number number of pending connections
ClosedChannelException - if the channel is closed
IOException - if some other I/O error occurs
public SocketAddress getLocalAddress()
throws IOException
null if the socket is not bound.
null
if the channel is not open
or the channel's socket is not bound
IOException - if an I/O error occurs
public AsyncServerSocketChannelImpl setOption(SocketOption name,
Object value)
throws IOException
The name parameter is the name of the socket option.
The value parameter is the value of the option and is of the
type specified by the option. A value of
null may be a valid value for some socket options.
setOption in interface NetworkChannelsetOption in class AsynchronousServerSocketChannelname - the name of the socket optionvalue - the value of the socket option
ClosedChannelException - if this channel is closed
IOException - if an I/O error occursSocketOption
public Object getOption(SocketOption name)
throws IOException
The return type is specific to the socket option and null
may be a valid value for some socket options.
name - the socket option
ClosedChannelException - if this channel is closed
IOException - if an I/O error occursSocketOptionpublic Set<SocketOption> options()
This method will continue to return the set of options even after the channel has been closed.
public boolean isAcceptPending()
The result of this method is a snapshot of the channel state. It may be invalid when the caller goes to examine the result and should not be used for the purpose of coordination.
isAcceptPending in class AsynchronousServerSocketChanneltrue if, and only if, an accept is pending for this
this channel but has not yet completed.
public <A> IoFuture<AsynchronousSocketChannel,A> accept(A attachment,
CompletionHandler<AsynchronousSocketChannel,? super A> handler)
This method initiates accepting a connection made to this channel's
socket, returning an IoFuture representing the pending result
of the operation. The IoFuture's get
method will return the AsynchronousSocketChannel for the new
connection on successful completion.
When a new connection is accepted then the resulting
AsynchronousSocketChannel will be bound to the same
AsynchronousChannelGroup as this channel.
If a security manager has been installed then it verifies that the
address and port number of the connection's remote endpoint are
permitted by the security manager's checkAccept method. The permission check is performed with privileges
that are restricted by the calling context of this method. If the
permission check fails then the operation completes by throwing
ExecutionException with cause SecurityException.
accept in class AsynchronousServerSocketChannelA - the attachment typeattachment - the object to attach to the
returned IoFuture object; can be nullhandler - the handler for consuming the result; can be
null
IoFuture object representing the pending result
|
RedDwarf, Version 0.10.1 2010-03-14 10:56:12 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||