Dela via


SelectableChannel.Register Method

Definition

Overloads

Register(Selector, Operations)

Registers this channel with the given selector, returning a selection key.

Register(Selector, Operations, Object)

Registers this channel with the given selector, returning a selection key.

Register(Selector, Operations)

Registers this channel with the given selector, returning a selection key.

[Android.Runtime.Register("register", "(Ljava/nio/channels/Selector;I)Ljava/nio/channels/SelectionKey;", "")]
public Java.Nio.Channels.SelectionKey? Register (Java.Nio.Channels.Selector? sel, Java.Nio.Channels.Operations ops);
[<Android.Runtime.Register("register", "(Ljava/nio/channels/Selector;I)Ljava/nio/channels/SelectionKey;", "")>]
member this.Register : Java.Nio.Channels.Selector * Java.Nio.Channels.Operations -> Java.Nio.Channels.SelectionKey

Parameters

sel
Selector

The selector with which this channel is to be registered

ops
Operations

The interest set for the resulting key

Returns

A key representing the registration of this channel with the given selector

Attributes

Exceptions

if the channel is closed.

if the channel is in blocking mode.

if this channel does not have the same provider as the given selector.

if this channel is registered but its key has been canceled.

if the operation given is not supported by this channel.

Remarks

Registers this channel with the given selector, returning a selection key.

An invocation of this convenience method of the form

<blockquote>sc.register(sel, ops)</blockquote>

behaves in exactly the same way as the invocation

<blockquote>sc.#register(java.nio.channels.Selector,int,java.lang.Object) register(sel, ops, null)</blockquote>

Java documentation for java.nio.channels.SelectableChannel.register(java.nio.channels.Selector, int).

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

Register(Selector, Operations, Object)

Registers this channel with the given selector, returning a selection key.

[Android.Runtime.Register("register", "(Ljava/nio/channels/Selector;ILjava/lang/Object;)Ljava/nio/channels/SelectionKey;", "GetRegister_Ljava_nio_channels_Selector_ILjava_lang_Object_Handler")]
public abstract Java.Nio.Channels.SelectionKey? Register (Java.Nio.Channels.Selector? sel, Java.Nio.Channels.Operations ops, Java.Lang.Object? att);
[<Android.Runtime.Register("register", "(Ljava/nio/channels/Selector;ILjava/lang/Object;)Ljava/nio/channels/SelectionKey;", "GetRegister_Ljava_nio_channels_Selector_ILjava_lang_Object_Handler")>]
abstract member Register : Java.Nio.Channels.Selector * Java.Nio.Channels.Operations * Java.Lang.Object -> Java.Nio.Channels.SelectionKey

Parameters

sel
Selector

The selector with which this channel is to be registered

ops
Operations

The interest set for the resulting key

att
Object

The attachment for the resulting key; may be null

Returns

A key representing the registration of this channel with the given selector

Attributes

Exceptions

if this channel is closed.

if ops is not supported by this channel.

if this channel is in blocking mode.

if this channel does not have the same provider as the given selector.

if this channel is registered but its key has been canceled.

Remarks

Registers this channel with the given selector, returning a selection key.

If this channel is currently registered with the given selector then the selection key representing that registration is returned. The key's interest set will have been changed to ops, as if by invoking the SelectionKey#interestOps(int) interestOps(int) method. If the att argument is not null then the key's attachment will have been set to that value. A CancelledKeyException will be thrown if the key has already been cancelled.

Otherwise this channel has not yet been registered with the given selector, so it is registered and the resulting new key is returned. The key's initial interest set will be ops and its attachment will be att.

This method may be invoked at any time. If this method is invoked while a selection operation is in progress then it has no effect upon that operation; the new registration or change to the key's interest set will be seen by the next selection operation. If this method is invoked while an invocation of #configureBlocking(boolean) configureBlocking is in progress then it will block until the channel's blocking mode has been adjusted.

If this channel is closed while this operation is in progress then the key returned by this method will have been cancelled and will therefore be invalid.

Java documentation for java.nio.channels.SelectableChannel.register(java.nio.channels.Selector, int, java.lang.Object).

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