# AsynchronousServerSocketChannel

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Protected Ctors](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel#proctors)\|[Methods](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel#inhmethods)  

# AsynchronousServerSocketChannel

`
public


abstract
class
AsynchronousServerSocketChannel
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


implements

`[AsynchronousChannel](https://developer.android.com/reference/java/nio/channels/AsynchronousChannel)`,

`[NetworkChannel](https://developer.android.com/reference/java/nio/channels/NetworkChannel)`


`

|---|---------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.nio.channels.AsynchronousServerSocketChannel |

<br />

*** ** * ** ***

An asynchronous channel for stream-oriented listening sockets.

An asynchronous server-socket channel is created by invoking the[open](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel#open())method of this class. A newly-created asynchronous server-socket channel is open but not yet bound. It can be bound to a local address and configured to listen for connections by invoking the[bind](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel#bind(java.net.SocketAddress,%20int))method. Once bound, the[accept](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel#accept(A,%20java.nio.channels.CompletionHandler<java.nio.channels.AsynchronousSocketChannel,?%20super%20A>))method is used to initiate the accepting of connections to the channel's socket. An attempt to invoke the`accept`method on an unbound channel will cause a[NotYetBoundException](https://developer.android.com/reference/java/nio/channels/NotYetBoundException)to be thrown.

Channels of this type are safe for use by multiple concurrent threads though at most one accept operation can be outstanding at any time. If a thread initiates an accept operation before a previous accept operation has completed then an[AcceptPendingException](https://developer.android.com/reference/java/nio/channels/AcceptPendingException)will be thrown.

Socket options are configured using the[setOption](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel#setOption(java.net.SocketOption<T>,%20T))method. Channels of this type support the following options:
>
> |                                             Option Name                                             |              Description              |
> |    [SO_RCVBUF](https://developer.android.com/reference/java/net/StandardSocketOptions#SO_RCVBUF)    | The size of the socket receive buffer |
> | [SO_REUSEADDR](https://developer.android.com/reference/java/net/StandardSocketOptions#SO_REUSEADDR) |            Re-use address             |
> |-----------------------------------------------------------------------------------------------------|---------------------------------------|
> [Socket options]

Additional (implementation specific) options may also be supported.

**Usage Example:**  

```
  final AsynchronousServerSocketChannel listener =
      AsynchronousServerSocketChannel.open().bind(new InetSocketAddress(5000));

  listener.accept(null, new CompletionHandler<AsynchronousSocketChannel,Void>() {
      public void completed(AsynchronousSocketChannel ch, Void att) {
          // accept the next connection
          listener.accept(null, this);

          // handle this connection
          handle(ch);
      }
      public void failed(Throwable exc, Void att) {
          ...
      }
  });
 
```

<br />

## Summary

|                                                                                                                                                                                       ### Protected constructors                                                                                                                                                                                        ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[AsynchronousServerSocketChannel](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel#AsynchronousServerSocketChannel(java.nio.channels.spi.AsynchronousChannelProvider))`(`[AsynchronousChannelProvider](https://developer.android.com/reference/java/nio/channels/spi/AsynchronousChannelProvider)` provider) ` Initializes a new instance of this class. |

|                                                                                                                                                                                                                                                                                                                                                  ### Public methods                                                                                                                                                                                                                                                                                                                                                   ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract `[Future](https://developer.android.com/reference/java/util/concurrent/Future)`<`[AsynchronousSocketChannel](https://developer.android.com/reference/java/nio/channels/AsynchronousSocketChannel)`>` | ` `[accept](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel#accept())`() ` Accepts a connection.                                                                                                                                                                                                                                                                                                                                                           |
| ` abstract <A> void`                                                                                                                                                                                            | ` `[accept](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel#accept(A,%20java.nio.channels.CompletionHandler<java.nio.channels.AsynchronousSocketChannel,?%20super%20A>))`(A attachment, `[CompletionHandler](https://developer.android.com/reference/java/nio/channels/CompletionHandler)`<`[AsynchronousSocketChannel](https://developer.android.com/reference/java/nio/channels/AsynchronousSocketChannel)`, ? super A> handler) ` Accepts a connection. |
| ` abstract `[AsynchronousServerSocketChannel](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel)                                                                        | ` `[bind](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel#bind(java.net.SocketAddress,%20int))`(`[SocketAddress](https://developer.android.com/reference/java/net/SocketAddress)` local, int backlog) ` Binds the channel's socket to a local address and configures the socket to listen for connections.                                                                                                                                                 |
| ` final `[AsynchronousServerSocketChannel](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel)                                                                           | ` `[bind](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel#bind(java.net.SocketAddress))`(`[SocketAddress](https://developer.android.com/reference/java/net/SocketAddress)` local) ` Binds the channel's socket to a local address and configures the socket to listen for connections.                                                                                                                                                                     |
| ` abstract `[SocketAddress](https://developer.android.com/reference/java/net/SocketAddress)                                                                                                                     | ` `[getLocalAddress](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel#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 `[AsynchronousServerSocketChannel](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel)                                                                          | ` `[open](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel#open(java.nio.channels.AsynchronousChannelGroup))`(`[AsynchronousChannelGroup](https://developer.android.com/reference/java/nio/channels/AsynchronousChannelGroup)` group) ` Opens an asynchronous server-socket channel.                                                                                                                                                                        |
| ` static `[AsynchronousServerSocketChannel](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel)                                                                          | ` `[open](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel#open())`() ` Opens an asynchronous server-socket channel.                                                                                                                                                                                                                                                                                                                                        |
| ` final `[AsynchronousChannelProvider](https://developer.android.com/reference/java/nio/channels/spi/AsynchronousChannelProvider)                                                                               | ` `[provider](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel#provider())`() ` Returns the provider that created this channel.                                                                                                                                                                                                                                                                                                                             |
| ` abstract <T> `[AsynchronousServerSocketChannel](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel)                                                                    | ` `[setOption](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel#setOption(java.net.SocketOption<T>,%20T))`(`[SocketOption](https://developer.android.com/reference/java/net/SocketOption)`<T> name, T value) ` Sets the value of a socket option.                                                                                                                                                                                                           |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||
| From interface` `[java.nio.channels.AsynchronousChannel](https://developer.android.com/reference/java/nio/channels/AsynchronousChannel)` ` |------------------|-----------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[close](https://developer.android.com/reference/java/nio/channels/AsynchronousChannel#close())`() ` Closes this channel. | ||
| From interface` `[java.nio.channels.NetworkChannel](https://developer.android.com/reference/java/nio/channels/NetworkChannel)` ` |----------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract `[NetworkChannel](https://developer.android.com/reference/java/nio/channels/NetworkChannel)                                                         | ` `[bind](https://developer.android.com/reference/java/nio/channels/NetworkChannel#bind(java.net.SocketAddress))`(`[SocketAddress](https://developer.android.com/reference/java/net/SocketAddress)` local) ` Binds the channel's socket to a local address.               | | ` abstract `[SocketAddress](https://developer.android.com/reference/java/net/SocketAddress)                                                                    | ` `[getLocalAddress](https://developer.android.com/reference/java/nio/channels/NetworkChannel#getLocalAddress())`() ` Returns the socket address that this channel's socket is bound to.                                                                                  | | ` abstract <T> T`                                                                                                                                              | ` `[getOption](https://developer.android.com/reference/java/nio/channels/NetworkChannel#getOption(java.net.SocketOption<T>))`(`[SocketOption](https://developer.android.com/reference/java/net/SocketOption)`<T> name) ` Returns the value of a socket option.            | | ` abstract <T> `[NetworkChannel](https://developer.android.com/reference/java/nio/channels/NetworkChannel)                                                     | ` `[setOption](https://developer.android.com/reference/java/nio/channels/NetworkChannel#setOption(java.net.SocketOption<T>,%20T))`(`[SocketOption](https://developer.android.com/reference/java/net/SocketOption)`<T> name, T value) ` Sets the value of a socket option. | | ` abstract `[Set](https://developer.android.com/reference/java/util/Set)`<`[SocketOption](https://developer.android.com/reference/java/net/SocketOption)`<?>>` | ` `[supportedOptions](https://developer.android.com/reference/java/nio/channels/NetworkChannel#supportedOptions())`() ` Returns a set of the socket options supported by this channel.                                                                                    | ||
| From interface` `[java.nio.channels.Channel](https://developer.android.com/reference/java/nio/channels/Channel)` ` |---------------------|-----------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void`    | ` `[close](https://developer.android.com/reference/java/nio/channels/Channel#close())`() ` Closes this channel.                         | | ` abstract boolean` | ` `[isOpen](https://developer.android.com/reference/java/nio/channels/Channel#isOpen())`() ` Tells whether or not this channel is open. | ||
| From interface` `[java.io.Closeable](https://developer.android.com/reference/java/io/Closeable)` ` |------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[close](https://developer.android.com/reference/java/io/Closeable#close())`() ` Closes this stream and releases any system resources associated with it. | ||
| From interface` `[java.lang.AutoCloseable](https://developer.android.com/reference/java/lang/AutoCloseable)` ` |------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[close](https://developer.android.com/reference/java/lang/AutoCloseable#close())`() ` Closes this resource, relinquishing any underlying resources. | ||

## Protected constructors

### AsynchronousServerSocketChannel

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected AsynchronousServerSocketChannel (AsynchronousChannelProvider provider)
```

Initializes a new instance of this class.

<br />

|                                        Parameters                                        ||
|------------|------------------------------------------------------------------------------|
| `provider` | `AsynchronousChannelProvider`: The provider that created this channel <br /> |

## Public methods

### accept

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract Future<AsynchronousSocketChannel> accept ()
```

Accepts a connection.

This method initiates an asynchronous operation to accept a connection made to this channel's socket. The method behaves in exactly the same manner as the[accept(java.lang.Object, java.nio.channels.CompletionHandler)](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel#accept(A,%20java.nio.channels.CompletionHandler<java.nio.channels.AsynchronousSocketChannel,?%20super%20A>))method except that instead of specifying a completion handler, this method returns a`Future`representing the pending result. The`Future`'s[get](https://developer.android.com/reference/java/util/concurrent/Future#get())method returns the[AsynchronousSocketChannel](https://developer.android.com/reference/java/nio/channels/AsynchronousSocketChannel)to the new connection on successful completion.

<br />

|                                                                                                                           Returns                                                                                                                           ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------|
| [Future](https://developer.android.com/reference/java/util/concurrent/Future)`<`[AsynchronousSocketChannel](https://developer.android.com/reference/java/nio/channels/AsynchronousSocketChannel)`>` | a`Future`object representing the pending result <br /> |

|                                                                                  Throws                                                                                   ||
|------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
| [AcceptPendingException](https://developer.android.com/reference/java/nio/channels/AcceptPendingException) | If an accept operation is already in progress on this channel |
| [NotYetBoundException](https://developer.android.com/reference/java/nio/channels/NotYetBoundException)     | If this channel's socket has not yet been bound               |

### accept

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void accept (A attachment, 
                CompletionHandler<AsynchronousSocketChannel, ? super A> handler)
```

Accepts a connection.

This method initiates an asynchronous operation to accept a connection made to this channel's socket. The`handler`parameter is a completion handler that is invoked when a connection is accepted (or the operation fails). The result passed to the completion handler is the[AsynchronousSocketChannel](https://developer.android.com/reference/java/nio/channels/AsynchronousSocketChannel)to the new connection.

When a new connection is accepted then the resulting`AsynchronousSocketChannel`will be bound to the same[AsynchronousChannelGroup](https://developer.android.com/reference/java/nio/channels/AsynchronousChannelGroup)as this channel. If the group is[shutdown](https://developer.android.com/reference/java/nio/channels/AsynchronousChannelGroup#isShutdown())and a connection is accepted, then the connection is closed, and the operation completes with an`IOException`and cause[ShutdownChannelGroupException](https://developer.android.com/reference/java/nio/channels/ShutdownChannelGroupException).

To allow for concurrent handling of new connections, the completion handler is not invoked directly by the initiating thread when a new connection is accepted immediately (see[Threading](https://developer.android.com/reference/java/nio/channels/AsynchronousChannelGroup#threading)).

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](https://developer.android.com/reference/java/lang/SecurityManager#checkAccept(java.lang.String,%20int))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 connection is closed and the operation completes with a[SecurityException](https://developer.android.com/reference/java/lang/SecurityException).

<br />

|                                    Parameters                                     ||
|--------------|---------------------------------------------------------------------|
| `attachment` | `A`: The object to attach to the I/O operation; can be`null` <br /> |
| `handler`    | `CompletionHandler`: The handler for consuming the result <br />    |

|                                                                                         Throws                                                                                          ||
|--------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
| [AcceptPendingException](https://developer.android.com/reference/java/nio/channels/AcceptPendingException)               | If an accept operation is already in progress on this channel |
| [NotYetBoundException](https://developer.android.com/reference/java/nio/channels/NotYetBoundException)                   | If this channel's socket has not yet been bound               |
| [ShutdownChannelGroupException](https://developer.android.com/reference/java/nio/channels/ShutdownChannelGroupException) | If the channel group has terminated                           |

### bind

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract AsynchronousServerSocketChannel bind (SocketAddress 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 associated 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.

<br />

|                                                              Parameters                                                              ||
|-----------|---------------------------------------------------------------------------------------------------------------------------|
| `local`   | `SocketAddress`: The local address to bind the socket, or`null`to bind to an automatically assigned socket address <br /> |
| `backlog` | `int`: The maximum number of pending connections <br />                                                                   |

|                                                                      Returns                                                                      ||
|------------------------------------------------------------------------------------------------------------------------------|---------------------|
| [AsynchronousServerSocketChannel](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel) | This channel <br /> |

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

### bind

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final AsynchronousServerSocketChannel bind (SocketAddress 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 />

<br />

|                                                             Parameters                                                             ||
|---------|---------------------------------------------------------------------------------------------------------------------------|
| `local` | `SocketAddress`: The local address to bind the socket, or`null`to bind to an automatically assigned socket address <br /> |

|                                                                      Returns                                                                      ||
|------------------------------------------------------------------------------------------------------------------------------|---------------------|
| [AsynchronousServerSocketChannel](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel) | This channel <br /> |

|                                                             Throws                                                              ||
|------------------------------------------------------------------------------------------------------------------------------|---|
| [AlreadyBoundException](https://developer.android.com/reference/java/nio/channels/AlreadyBoundException)                     |   |
| [UnsupportedAddressTypeException](https://developer.android.com/reference/java/nio/channels/UnsupportedAddressTypeException) |   |
| [SecurityException](https://developer.android.com/reference/java/lang/SecurityException)                                     |   |
| [ClosedChannelException](https://developer.android.com/reference/java/nio/channels/ClosedChannelException)                   |   |
| [IOException](https://developer.android.com/reference/java/io/IOException)                                                   |   |

### getLocalAddress

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract SocketAddress getLocalAddress ()
```

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

Where the channel is[bound](https://developer.android.com/reference/java/nio/channels/NetworkChannel#bind(java.net.SocketAddress))to an Internet Protocol socket address then the return value from this method is of type[InetSocketAddress](https://developer.android.com/reference/java/net/InetSocketAddress).

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[loopback](https://developer.android.com/reference/java/net/InetAddress#getLoopbackAddress())address and the local port of the channel's socket is returned.

<br />

|                                                                                                                                    Returns                                                                                                                                    ||
|---------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [SocketAddress](https://developer.android.com/reference/java/net/SocketAddress) | 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 <br /> |

|                                                    Throws                                                     ||
|------------------------------------------------------------------------------------------------------------|---|
| [ClosedChannelException](https://developer.android.com/reference/java/nio/channels/ClosedChannelException) |   |
| [IOException](https://developer.android.com/reference/java/io/IOException)                                 |   |

### open

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static AsynchronousServerSocketChannel open (AsynchronousChannelGroup group)
```

Opens an asynchronous server-socket channel.

The new channel is created by invoking the[openAsynchronousServerSocketChannel](https://developer.android.com/reference/java/nio/channels/spi/AsynchronousChannelProvider#openAsynchronousServerSocketChannel(java.nio.channels.AsynchronousChannelGroup))method on the[AsynchronousChannelProvider](https://developer.android.com/reference/java/nio/channels/spi/AsynchronousChannelProvider)object that created the given group. If the group parameter is`null`then the resulting channel is created by the system-wide default provider, and bound to the*default group*.

<br />

|                                                                 Parameters                                                                  ||
|---------|------------------------------------------------------------------------------------------------------------------------------------|
| `group` | `AsynchronousChannelGroup`: The group to which the newly constructed channel should be bound, or`null`for the default group <br /> |

|                                                                                    Returns                                                                                    ||
|------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------|
| [AsynchronousServerSocketChannel](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel) | A new asynchronous server socket channel <br /> |

|                                                                           Throws                                                                           ||
|--------------------------------------------------------------------------------------------------------------------------|----------------------------------|
| [ShutdownChannelGroupException](https://developer.android.com/reference/java/nio/channels/ShutdownChannelGroupException) | If the channel group is shutdown |
| [IOException](https://developer.android.com/reference/java/io/IOException)                                               | If an I/O error occurs           |

### open

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static AsynchronousServerSocketChannel open ()
```

Opens an asynchronous server-socket channel.

This method returns an asynchronous server socket channel that is bound to the*default group*. This method is equivalent to evaluating the expression:
>
> ```
>  open((AsynchronousChannelGroup)null);
>  
> ```

<br />

<br />

|                                                                                    Returns                                                                                    ||
|------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------|
| [AsynchronousServerSocketChannel](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel) | A new asynchronous server socket channel <br /> |

|                                               Throws                                               ||
|----------------------------------------------------------------------------|------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | If an I/O error occurs |

### provider

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final AsynchronousChannelProvider provider ()
```

Returns the provider that created this channel.

<br />

|                                                                                 Returns                                                                                 ||
|--------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------|
| [AsynchronousChannelProvider](https://developer.android.com/reference/java/nio/channels/spi/AsynchronousChannelProvider) | The provider that created this channel <br /> |

### setOption

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract AsynchronousServerSocketChannel setOption (SocketOption<T> name, 
                T value)
```

Sets the value of a socket option.

<br />

|                                                     Parameters                                                     ||
|---------|-----------------------------------------------------------------------------------------------------------|
| `name`  | `SocketOption`: The socket option <br />                                                                  |
| `value` | `T`: The value of the socket option. A value of`null`may be a valid value for some socket options. <br /> |

|                                                                      Returns                                                                      ||
|------------------------------------------------------------------------------------------------------------------------------|---------------------|
| [AsynchronousServerSocketChannel](https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel) | This channel <br /> |

|                                                    Throws                                                     ||
|------------------------------------------------------------------------------------------------------------|---|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException)     |   |
| [ClosedChannelException](https://developer.android.com/reference/java/nio/channels/ClosedChannelException) |   |
| [IOException](https://developer.android.com/reference/java/io/IOException)                                 |   |