AsynchronousServerSocketChannel.Accept Method

Definition

Overloads

Accept()

Accepts a connection.

Accept(Object, ICompletionHandler)

Accepts a connection.

Accept()

Accepts a connection.

[Android.Runtime.Register("accept", "()Ljava/util/concurrent/Future;", "GetAcceptHandler", ApiSince=26)]
public abstract Java.Util.Concurrent.IFuture? Accept ();
[<Android.Runtime.Register("accept", "()Ljava/util/concurrent/Future;", "GetAcceptHandler", ApiSince=26)>]
abstract member Accept : unit -> Java.Util.Concurrent.IFuture

Returns

a Future object representing the pending result

Attributes

Remarks

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(Object, CompletionHandler) method except that instead of specifying a completion handler, this method returns a Future representing the pending result. The Future's Future#get() get method returns the AsynchronousSocketChannel to the new connection on successful completion.

Java documentation for java.nio.channels.AsynchronousServerSocketChannel.accept().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Accept(Object, ICompletionHandler)

Accepts a connection.

[Android.Runtime.Register("accept", "(Ljava/lang/Object;Ljava/nio/channels/CompletionHandler;)V", "GetAccept_Ljava_lang_Object_Ljava_nio_channels_CompletionHandler_Handler", ApiSince=26)]
[Java.Interop.JavaTypeParameters(new System.String[] { "A" })]
public abstract void Accept (Java.Lang.Object? attachment, Java.Nio.Channels.ICompletionHandler? handler);
[<Android.Runtime.Register("accept", "(Ljava/lang/Object;Ljava/nio/channels/CompletionHandler;)V", "GetAccept_Ljava_lang_Object_Ljava_nio_channels_CompletionHandler_Handler", ApiSince=26)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "A" })>]
abstract member Accept : Java.Lang.Object * Java.Nio.Channels.ICompletionHandler -> unit

Parameters

attachment
Object

The object to attach to the I/O operation; can be null

handler
ICompletionHandler

The handler for consuming the result

Attributes

Remarks

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 to the new connection.

When a new connection is accepted then the resulting AsynchronousSocketChannel will be bound to the same AsynchronousChannelGroup as this channel. If the group is AsynchronousChannelGroup#isShutdown shutdown and a connection is accepted, then the connection is closed, and the operation completes with an IOException and cause 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).

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 SecurityManager#checkAccept 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 connection is closed and the operation completes with a SecurityException.

Java documentation for java.nio.channels.AsynchronousServerSocketChannel.accept(A, java.nio.channels.CompletionHandler<java.nio.channels.AsynchronousSocketChannel, ? super A>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to