# ServerSocketChannel

public abstract class **ServerSocketChannel** extends [AbstractSelectableChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html)  
implements [NetworkChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NetworkChannel.html) A selectable channel for stream-oriented listening sockets.

A server-socket channel is created by invoking the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html#open()`
method of this class. It is not possible to create a channel for an arbitrary,
pre-existing `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html`. A newly-created server-socket channel is
open but not yet bound. An attempt to invoke the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html#accept()`
method of an unbound server-socket channel will cause a `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NotYetBoundException.html`
to be thrown. A server-socket channel can be bound by invoking one of the
`https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html#bind(java.net.SocketAddress,%20int)` methods defined by this class.

Socket options are configured using the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html#setOption(java.net.SocketOption<T>,%20T)` method. Server-socket channels support the following options:
>
> | Option Name | Description |
> |---|---|
> | `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/StandardSocketOptions.html#SO_RCVBUF` | The size of the socket receive buffer |
> | `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/StandardSocketOptions.html#SO_REUSEADDR` | Re-use address |

Additional (implementation specific) options may also be supported.

Server-socket channels are safe for use by multiple concurrent threads.

<br />

### Protected Constructor Summary

|---|---|
|   | [ServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html#ServerSocketChannel(java.nio.channels.spi.SelectorProvider))([SelectorProvider](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html) provider) Initializes a new instance of this class. |

### Public Method Summary

|---|---|
| abstract [SocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SocketChannel.html) | [accept](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html#accept())() Accepts a connection made to this channel's socket. |
| abstract [ServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html) | [bind](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html#bind(java.net.SocketAddress,%20int))([SocketAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketAddress.html) local, int backlog) Binds the channel's socket to a local address and configures the socket to listen for connections. |
| final [ServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html) | [bind](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html#bind(java.net.SocketAddress))([SocketAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketAddress.html) local) Binds the channel's socket to a local address and configures the socket to listen for connections. |
| abstract [SocketAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketAddress.html) | [getLocalAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html#getLocalAddress())() Returns the socket address that this channel's socket is bound to. If there is a security manager set, its `checkConnect` method is called with the local address and `-1` as its arguments to see if the operation is allowed. |
| static [ServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html) | [open](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html#open())() Opens a server-socket channel. |
| abstract \<T\> [ServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html) | [setOption](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html#setOption(java.net.SocketOption<T>,%20T))([SocketOption](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOption.html)\<T\> name, T value) Sets the value of a socket option. |
| abstract [ServerSocket](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html) | [socket](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html#socket())() Retrieves a server socket associated with this channel. |
| final int | [validOps](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html#validOps())() Returns an operation set identifying this channel's supported operations. |

### Inherited Method Summary

From class [java.nio.channels.spi.AbstractSelectableChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html)

|---|---|
| final [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [blockingLock](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#blockingLock())() Retrieves the object upon which the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#configureBlocking(boolean)` and `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#register(java.nio.channels.Selector,%20int)` methods synchronize. |
| final [SelectableChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html) | [configureBlocking](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#configureBlocking(boolean))(boolean block) Adjusts this channel's blocking mode. |
| final void | [implCloseChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#implCloseChannel())() Closes this channel. |
| abstract void | [implCloseSelectableChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#implCloseSelectableChannel())() Closes this selectable channel. |
| abstract void | [implConfigureBlocking](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#implConfigureBlocking(boolean))(boolean block) Adjusts this channel's blocking mode. |
| final boolean | [isBlocking](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#isBlocking())() Tells whether or not every I/O operation on this channel will block until it completes. |
| final boolean | [isRegistered](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#isRegistered())() Tells whether or not this channel is currently registered with any selectors. |
| final [SelectionKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html) | [keyFor](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#keyFor(java.nio.channels.Selector))([Selector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Selector.html) sel) Retrieves the key representing the channel's registration with the given selector. |
| final [SelectorProvider](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html) | [provider](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#provider())() Returns the provider that created this channel. |
| final [SelectionKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html) | [register](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#register(java.nio.channels.Selector,%20int,%20java.lang.Object))([Selector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Selector.html) sel, int ops, [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) att) Registers this channel with the given selector, returning a selection key. |

From class [java.nio.channels.SelectableChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html)

|---|---|
| abstract [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [blockingLock](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#blockingLock())() Retrieves the object upon which the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#configureBlocking(boolean)` and `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#register(java.nio.channels.Selector,%20int)` methods synchronize. |
| abstract [SelectableChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html) | [configureBlocking](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#configureBlocking(boolean))(boolean block) Adjusts this channel's blocking mode. |
| abstract boolean | [isBlocking](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#isBlocking())() Tells whether or not every I/O operation on this channel will block until it completes. |
| abstract boolean | [isRegistered](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#isRegistered())() Tells whether or not this channel is currently registered with any selectors. |
| abstract [SelectionKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html) | [keyFor](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#keyFor(java.nio.channels.Selector))([Selector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Selector.html) sel) Retrieves the key representing the channel's registration with the given selector. |
| abstract [SelectorProvider](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html) | [provider](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#provider())() Returns the provider that created this channel. |
| abstract [SelectionKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html) | [register](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#register(java.nio.channels.Selector,%20int,%20java.lang.Object))([Selector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Selector.html) sel, int ops, [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) att) Registers this channel with the given selector, returning a selection key. |
| final [SelectionKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html) | [register](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#register(java.nio.channels.Selector,%20int))([Selector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Selector.html) sel, int ops) Registers this channel with the given selector, returning a selection key. |
| abstract int | [validOps](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#validOps())() Returns an [operation set](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey#opsets) identifying this channel's supported operations. |

From class [java.nio.channels.spi.AbstractInterruptibleChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractInterruptibleChannel.html)

|---|---|
| final void | [begin](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractInterruptibleChannel.html#begin())() Marks the beginning of an I/O operation that might block indefinitely. |
| final void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractInterruptibleChannel.html#close())() Closes this channel. |
| final void | [end](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractInterruptibleChannel.html#end(boolean))(boolean completed) Marks the end of an I/O operation that might block indefinitely. |
| abstract void | [implCloseChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractInterruptibleChannel.html#implCloseChannel())() Closes this channel. |
| final boolean | [isOpen](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractInterruptibleChannel.html#isOpen())() Tells whether or not this channel is open. |

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

From interface [java.nio.channels.Channel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Channel.html)

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Channel.html#close())() Closes this channel. |
| abstract boolean | [isOpen](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Channel.html#isOpen())() Tells whether or not this channel is open. |

From interface [java.nio.channels.InterruptibleChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/InterruptibleChannel.html)

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/InterruptibleChannel.html#close())() Closes this channel. |

From interface [java.nio.channels.NetworkChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NetworkChannel.html)

|---|---|
| abstract [NetworkChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NetworkChannel.html) | [bind](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NetworkChannel.html#bind(java.net.SocketAddress))([SocketAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketAddress.html) local) Binds the channel's socket to a local address. |
| abstract [SocketAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketAddress.html) | [getLocalAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NetworkChannel.html#getLocalAddress())() Returns the socket address that this channel's socket is bound to. |
| abstract \<T\> T | [getOption](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NetworkChannel.html#getOption(java.net.SocketOption<T>))([SocketOption](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOption.html)\<T\> name) Returns the value of a socket option. |
| abstract \<T\> [NetworkChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NetworkChannel.html) | [setOption](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NetworkChannel.html#setOption(java.net.SocketOption<T>,%20T))([SocketOption](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOption.html)\<T\> name, T value) Sets the value of a socket option. |
| abstract [Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[SocketOption](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOption.html)\<?\>\> | [supportedOptions](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NetworkChannel.html#supportedOptions())() Returns a set of the socket options supported by this channel. |

From interface [java.io.Closeable](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Closeable.html)

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Closeable.html#close())() Closes this stream and releases any system resources associated with it. |

From interface [java.lang.AutoCloseable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/AutoCloseable.html)

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/AutoCloseable.html#close())() Closes this resource, relinquishing any underlying resources. |

## Protected Constructors

#### protected
**ServerSocketChannel**
([SelectorProvider](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html) provider)

Initializes a new instance of this class.

##### Parameters

| provider | The provider that created this channel |
|---|---|

## Public Methods

#### public abstract [SocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SocketChannel.html)
**accept**
()

Accepts a connection made to this channel's socket.

If this channel is in non-blocking mode then this method will
immediately return null if there are no pending connections.
Otherwise it will block indefinitely until a new connection is available
or an I/O error occurs.

The socket channel returned by this method, if any, will be in
blocking mode regardless of the blocking mode of this channel.

This method performs exactly the same security checks as the `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html#accept()` method of the `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html` class. That is, if a security manager has been
installed then for each new connection this method verifies that the
address and port number of the connection's remote endpoint are
permitted by the security manager's `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityManager.html#checkAccept(java.lang.String,%20int)` method.

<br />

##### Returns

- The socket channel for the new connection, or null if this channel is in non-blocking mode and no connection is available to be accepted

##### Throws

| [ClosedChannelException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ClosedChannelException.html) | If this channel is closed |
| [AsynchronousCloseException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousCloseException.html) | If another thread closes this channel while the accept operation is in progress |
| [ClosedByInterruptException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ClosedByInterruptException.html) | If another thread interrupts the current thread while the accept operation is in progress, thereby closing the channel and setting the current thread's interrupt status |
| [NotYetBoundException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NotYetBoundException.html) | If this channel's socket has not yet been bound |
| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | If a security manager has been installed and it does not permit access to the remote endpoint of the new connection |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If some other I/O error occurs |
|---|---|

#### public abstract [ServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html)
**bind**
([SocketAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketAddress.html) local, int backlog)

Binds the channel's socket to a local address and configures the socket to
listen for connections.

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 channel is closed.

The `backlog` parameter is the maximum number of pending
connections on the socket. Its exact semantics are implementation specific.
In particular, an implementation may impose a maximum length or may choose
to ignore the parameter altogther. If the `backlog` parameter has
the value `0`, or a negative value, then an implementation specific
default is used.

##### Parameters

| local | The address to bind the socket, or `null` to bind to an automatically assigned socket address |
| backlog | The maximum number of pending connections |
|---|---|

##### Returns

- This channel

##### Throws

| [AlreadyBoundException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AlreadyBoundException.html) | If the socket is already bound |
| [UnsupportedAddressTypeException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/UnsupportedAddressTypeException.html) | If the type of the given address is not supported |
| [ClosedChannelException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ClosedChannelException.html) | If this channel is closed |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If some other I/O error occurs |
| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | If a security manager has been installed and its `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityManager.html#checkListen(int)` method denies the operation |
|---|---|

#### public final [ServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html)
**bind**
([SocketAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketAddress.html) local)

Binds the channel's socket to a local address and configures the socket
to listen for connections.

An invocation of this method is equivalent to the following:
>
> ```
>  bind(local, 0);
>  
> ```

<br />

##### Parameters

| local | The local address to bind the socket, or `null` to bind to an automatically assigned socket address |
|---|---|

##### Returns

- This channel

##### Throws

| [AlreadyBoundException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AlreadyBoundException.html) |   |
| [UnsupportedAddressTypeException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/UnsupportedAddressTypeException.html) |   |
| [ClosedChannelException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ClosedChannelException.html) |   |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) |   |
| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | If a security manager has been installed and its `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityManager.html#checkListen(int)` method denies the operation |
|---|---|

#### public abstract [SocketAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketAddress.html)
**getLocalAddress**
()

Returns the socket address that this channel's socket is bound to.

Where the channel is `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NetworkChannel.html#bind(java.net.SocketAddress)` to an Internet Protocol
socket address then the return value from this method is of type `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/InetSocketAddress.html`.


If there is a security manager set, its `checkConnect` method is
called with the local address and `-1` as its arguments to see
if the operation is allowed. If the operation is not allowed,
a `SocketAddress` representing the
`https://developers.google.com/j2objc/javadoc/jre/reference/java/net/InetAddress.html#getLoopbackAddress()` address and the
local port of the channel's socket is returned.

##### Returns

- The `SocketAddress` that the socket is bound to, or the `SocketAddress` representing the loopback address if denied by the security manager, or `null` if the channel's socket is not bound

##### Throws

| [ClosedChannelException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ClosedChannelException.html) |   |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) |   |
|---|---|

#### public static [ServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html)
**open**
()

Opens a server-socket channel.

The new channel is created by invoking the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html#openServerSocketChannel()` method of the system-wide default `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html` object.

The new channel's socket is initially unbound; it must be bound to a
specific address via one of its socket's `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html#bind(java.net.SocketAddress)` methods before
connections can be accepted.

<br />

##### Returns

- A new socket channel

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If an I/O error occurs |
|---|---|

#### public abstract [ServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html)
**setOption**
([SocketOption](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOption.html)\<T\> name, T value)

Sets the value of a socket option.

##### Parameters

| name | The socket option |
| value | The value of the socket option. A value of `null` may be a valid value for some socket options. |
|---|---|

##### Returns

- This channel

##### Throws

| [UnsupportedOperationException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/UnsupportedOperationException.html) |   |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) |   |
| [ClosedChannelException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ClosedChannelException.html) |   |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) |   |
|---|---|

#### public abstract [ServerSocket](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html)
**socket**
()

Retrieves a server socket associated with this channel.

The returned object will not declare any public methods that are not
declared in the `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html` class.

<br />

##### Returns

- A server socket associated with this channel

#### public final int
**validOps**
()

Returns an operation set identifying this channel's supported
operations.

Server-socket channels only support the accepting of new
connections, so this method returns `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html#OP_ACCEPT`.

<br />

##### Returns

- The valid-operation set