DotNetty.Transport This is a helper class that makes it easy to bootstrap an . It supports method- chaining to provide an easy way to configure the . When not used in a context, the methods are useful for connectionless transports such as datagram (UDP). Specifies the which will handle events for the being built. The which is used to handle all the events for the to-be-created . The instance. Specifies the of which will be created. The which is used to create instances from. The instance. Assigns the which is used to bind the local "end" to. The instance to bind the local "end" to. The instance. Assigns the local which is used to bind the local "end" to. This overload binds to a for any IP address on the local machine, given a specific port. The port to bind the local "end" to. The instance. Assigns the local which is used to bind the local "end" to. This overload binds to a for a given hostname and port. The hostname to bind the local "end" to. The port to bind the local "end" to. The instance. Assigns the local which is used to bind the local "end" to. This overload binds to a for a given and port. The to bind the local "end" to. The port to bind the local "end" to. The instance. Allows the specification of a which is used for the instances once they get created. Use a value of null to remove a previously set . The to configure. The value to set the given option. Allows specification of an initial attribute of the newly created . If the value is null, the attribute of the specified key is removed. Validates all the parameters. Sub-classes may override this, but should call the super method in that case. Returns a deep clone of this bootstrap which has the identical configuration. This method is useful when making multiple s with similar settings. Please note that this method does not clone the deeply but shallowly, making the group a shared resource. Creates a new and registers it with an . Creates a new and binds it to the endpoint specified via the methods. The bound . Creates a new and binds it. This overload binds to a for any IP address on the local machine, given a specific port. The port to bind the local "end" to. The bound . Creates a new and binds it. This overload binds to a for a given hostname and port. The hostname to bind the local "end" to. The port to bind the local "end" to. The bound . Creates a new and binds it. This overload binds to a for a given and port. The to bind the local "end" to. The port to bind the local "end" to. The bound . Creates a new and binds it. The instance to bind the local "end" to. The bound . Specifies the to use for serving the requests. The to use for serving requests. The instance. Returns the configured or null if none is configured yet. A that makes it easy to bootstrap an to use for clients. The methods are useful in combination with connectionless transports such as datagram (UDP). For regular TCP connections, please use the provided methods. Sets the which will resolve the address of the unresolved named address. The which will resolve the address of the unresolved named address. The instance. Assigns the remote to connect to once the method is called. The remote to connect to. The instance. Assigns the remote to connect to once the method is called. The hostname of the endpoint to connect to. The port at the remote host to connect to. The instance. Assigns the remote to connect to once the method is called. The of the endpoint to connect to. The port at the remote host to connect to. The instance. Connects an to the remote peer. The . Connects an to the remote peer. The hostname of the endpoint to connect to. The port at the remote host to connect to. The . Connects an to the remote peer. The of the endpoint to connect to. The port at the remote host to connect to. The . Connects an to the remote peer. The remote to connect to. The . Connects an to the remote peer. The remote to connect to. The local to connect to. The . Performs DNS resolution for the remote endpoint and connects to it. The remote to connect to. The local to connect the remote to. The . Returns a deep clone of this bootstrap which has the identical configuration except that it uses the given . This method is useful when making multiple s with similar settings. A sub-class which allows easy bootstrapping of . Specifies the which is used for the parent (acceptor) and the child (client). Sets the for the parent (acceptor) and the child (client). These 's are used to handle all the events and IO for and 's. Allows specification of a which is used for the instances once they get created (after the acceptor accepted the ). Use a value of null to remove a previously set . Sets the specific with the given value on every child . If the value is null, the is removed. Sets the which is used to serve the request for the 's. Returns the configured which will be used for the child channels or null if none is configured yet. Cache for the string representation of this channel Creates a new instance. The parent of this channel. Pass null if there's no parent. Creates a new instance. The parent of this channel. Pass null if there's no parent. An for the new channel. Resets the stored . Returns a new instance. Subclasses may override this method to assign custom s to s that use the constructor. A new instance. Returns a new pipeline instance. Create a new instance which will be used for the life-time of the Returns the ID of this channel. Returns true if and only if the specified object is identical with this channel (i.e. this == o). Returns the string representation of this channel. The returned string contains a hex dump of the , the , and the of this channel for easier identification. implementation which sub-classes must extend and use. true if the channel has never been registered, false otherwise /// This method must NEVER be called directly, but be executed as an extra task with a clean call stack instead. The reason for this is that this method calls directly, which might lead to an unfortunate nesting of independent inbound/outbound events. See the comments input for more details. Prepares to close the . If this method returns an , the caller must call the method with a task that calls on the returned . If this method returns null, must be called from the caller thread. (i.e. ) Checks whether a given is compatible with the . The to check compatibility. true if the given is compatible with this instance, otherwise false. Is called after the is registered with its as part of the register process. Sub-classes may override this method. Binds the to the . The to bind. Disconnects this from its remote peer. Closes the . Deregisters the from its . Sub-classes may override this method. ScheduleAsync a read operation. Flush the content of the given buffer to the remote peer. Invoked when a new message is added to a of this , so that the implementation converts the message to another. (e.g. heap buffer -> direct buffer). The message to be filtered. The filtered message. Neither nor was called. was called. was called. Makes best possible effort to detect if was called yet. If not return false and if called or could not detect return true. If this method returns true we will not invoke the but just forward the event. This is needed as may already put the in the linked-list but not called A skeletal server-side implementation. A server-side does not allow the following operations: , , , . Creates a new instance. The that automatically increases and decreases the predicted buffer size on feed back.

It gradually increases the expected number of readable bytes if the previous read fully filled the allocated buffer. It gradually decreases the expected number of readable bytes if the read operation was not able to fill a certain amount of the allocated buffer two times consecutively. Otherwise, it keeps returning the same prediction.

Creates a new predictor with the default parameters. With the default parameters, the expected buffer size starts from 1024, does not go down below 64, and does not go up above 65536. Creates a new predictor with the specified parameters. the inclusive lower bound of the expected buffer size the initial buffer size when no feed back was received the inclusive upper bound of the expected buffer size that works as a wrapper for another providing affinity on call. Creates a new instance of . serving as an actual provider of s. If running in a context of an existing , this is returned. Otherwise, is retrieved from underlying . A queue of write operations which are pending for later execution. It also updates the writability of the associated , so that the pending write operations are also considered to determine the writability. Returns true if there are no pending write operations left in this queue. Returns the number of pending write operations. Add the given msg and returns for completion of processing msg. Remove all pending write operation and fail them with the given . The messages will be released via . Remove a pending write operation and fail it with the given . The message will be released via . Remove all pending write operation and performs them via . if something was written and null if the is empty. Removes a pending write operation and performs it via . if something was written and null if the is empty. Removes a pending write operation and release it's message via . of the pending write or null if the queue is empty. Return the current message or null if empty. Holds all meta-data and construct the linked-list structure. It is a good starting point if your implementation needs to intercept operations and also state updates. A special which offers an easy way to initialize a once it was registered to its . Implementations are most often used in the context of and to setup the of a . Be aware that this class is marked as Sharable (via ) and so the implementation must be safe to be re-used. public class MyChannelInitializer extends { public void InitChannel( channel) { channel.Pipeline().AddLast("myHandler", new MyHandler()); } } bootstrap = ...; ... bootstrap.childHandler(new MyChannelInitializer()); ... A sub-type of . This method will be called once the was registered. After the method returns this instance will be removed from the of the . The which was registered. Represents the properties of a implementation. Create a new instance true if and only if the channel has the DisconnectAsync() operation that allows a user to disconnect and then call again, such as UDP/IP. Create a new instance true if and only if the channel has the DisconnectAsync operation that allows a user to disconnect and then call again, such as UDP/IP. If a is in use, then this value will be set for . Must be > 0. Returns true if and only if the channel has the DisconnectAsync() operation that allows a user to disconnect and then call again, such as UDP/IP. If a is in use, then this is the default value for . Returns the of the specified name. The type of option being retrieved. The name of the desired option. The matching instance. Returns the of the given pair: (, secondary name) The type of option being retrieved. A whose name will be used as the first part of the desired option's name. A string representing the second part of the desired option's name. The matching instance. Checks whether a given exists. The name of the . true if a exists for the given , otherwise false. Creates a new for the given . The type of option to create. The name to associate with the new option. Thrown if a for the given exists. The new instance. Adds the given message to this . The given will be notified once the message was written. The message to add to the buffer. The size of the message. The to notify once the message is written. Add a flush to this . This means all previous added messages are marked as flushed and so you will be able to handle them. Increments the number of pending bytes which will be written at some point. This method is thread-safe! The number of bytes to increment the count by. Decrements the number of pending bytes which will be written at some point. This method is thread-safe! The number of bytes to decrement the count by. Returns the current message to write, or null if nothing was flushed before and so is ready to be written. Notify the of the current message about writing progress. Removes the current message, marks its as complete, and returns true. If no flushed message exists at the time this method is called, it returns false to signal that no more messages are ready to be handled. true if a message existed and was removed, otherwise false. Removes the current message, marks its as complete using the given , and returns true. If no flushed message exists at the time this method is called, it returns false to signal that no more messages are ready to be handled. The causing the message to be removed. true if a message existed and was removed, otherwise false. Removes the fully written entries and updates the reader index of the partially written entry. This operation assumes all messages in this buffer are instances. The number of bytes that have been written so far. Clears all ByteBuffer from the array so these can be GC'ed. See https://github.com/netty/netty/issues/3837 Returns a list of direct ArraySegment<byte>, if the currently pending messages are made of instances only. will return the total number of readable bytes of these buffers. Note that the returned array is reused and thus should not escape . Refer to for an example. A list of ArraySegment<byte> buffers. Returns a list of direct ArraySegment<byte>, if the currently pending messages are made of instances only. will return the total number of readable bytes of these buffers. Note that the returned array is reused and thus should not escape . Refer to for an example. The maximum amount of buffers that will be added to the return value. A hint toward the maximum number of bytes to include as part of the return value. Note that this value maybe exceeded because we make a best effort to include at least 1 in the return value to ensure write progress is made. A list of ArraySegment<byte> buffers. Returns the number of bytes that can be written out of the array that was obtained via . This method MUST be called after . Returns true if and only if the total number of pending bytes () did not exceed the write watermark of the and no user-defined writability flag () has been set to false. Returns true if and only if the user-defined writability flag at the specified index is set to true. The index to check for user-defined writability. true if the user-defined writability flag at the specified index is set to true. Sets a user-defined writability flag at the specified index. The index where a writability flag should be set. Whether to set the index as writable or not. Returns the number of flushed messages in this . Returns true if there are flushed messages in this , otherwise false. Gets the number of bytes that can be written before returns false. This quantity will always be non-negative. If is already false, then 0 is returned. The number of bytes that can be written before returns false. Gets the number of bytes that must be drained from the underlying buffer before returns true. This quantity will always be non-negative. If is already true, then 0 is returned. The number of bytes that can be written before returns true. Calls for each flushed message in this until returns false or there are no more flushed messages to process. The intance to use to process each flushed message. Will be called for each flushed message until it either there are no more flushed messages or this method returns false. The message to process. true if the given message was successfully processed, otherwise false. Shared configuration for SocketAsyncChannel. Provides access to pre-configured resources like ByteBuf allocator and IO buffer pools This is the head of a linked list that is processed by and so process all the pending . We only keep the head because it is expected that the list is used infrequently and its size is small. Thus full iterations to do insertions is assumed to be a good compromised to saving memory and tail management complexity. Set to true once the is registered. Once set to true, the value will never change. Returns the string representation of this pipeline. Removes all handlers from the pipeline one by one from tail (exclusive) to head (exclusive) to trigger . Note that we traverse up the pipeline before traversing down so that the handlers are removed after all events are handled. See: https://github.com/netty/netty/issues/3156 Called once an hits the end of the without being handled by the user in . Called once a message hits the end of the without being handled by the user in . This method is responsible for calling on the given msg at some point. Default implementation of which respects and also prevents overflow. Focuses on enforcing the maximum messages per read condition for . Only is used. Returns the default implementation, which returns 0 for unknown messages. Creates a new instance. The size which is returned for unknown messages. Create a new instance with an empty pipeline. Create a new instance with an empty pipeline with the specified . The of this channel. Create a new instance with the pipeline initialized with the specified handlers. The s that will be added to the Create a new instance with the pipeline initialized with the specified handlers. The of this channel. false if this will delegate to , true otherwise. The s that will be added to the Returns the which holds all of the s that were received by this . Returns the which holds all of the s that were written by this . Return received data from this . Read data from the outbound. This may return null if nothing is readable. Run all tasks (which also includes scheduled tasks) that are pending in the for this . Run all pending scheduled tasks in the for this . The when the next scheduled task is ready to run. If no other task is scheduled then it will return . Write messages to the inbound of this The messages to be written. true if the write operation did add something to the inbound buffer Write messages to the outbound of this . The messages to be written. true if the write operation did add something to the inbound buffer Mark this as finished. Any further try to write data to it will fail. bufferReadable returns true Marks this as finished and releases all pending message in the inbound and outbound buffer. Any futher try to write data to it will fail. true if any of the used buffers has something left to read, otherwise false. Marks this as finished. Any futher attempt to write data to it will fail. If true, all pending messages in the inbound and outbound buffer are released. true if any of the used buffers has something left to read, otherwise false. Releases all buffered inbound messages. true if any were in the inbound buffer, otherwise false. Releases all buffered outbound messages. true if any were in the outbound buffer, otherwise false. Check to see if there was any and rethrow if so. Ensure the is open and if not throw an exception. A dummy implementation The that always yields the same buffer size prediction. This predictor ignores the feedback from the I/O thread. Creates a new predictor that always returns the same prediction of the specified buffer size. Returns the name of this group. A group name is purely for helping you to distinguish one group from others. Return the of the which describe the nature of the . The of the was registered with its . The of the was unregistered from its . Gets called once the writable state of a changed. You can check the state with . Called once a bind operation is made. The for which the bind operation is made. The to which it should bind. An await-able task. Called once a connect operation is made. The for which the connect operation is made. The to which it should connect. The which is used as source on connect. An await-able task. Called once a disconnect operation is made. The for which the disconnect operation is made. An await-able task. Returns the which is used to execute an arbitrary task. The unique name of the . The name was used when the was added to the . This name can also be used to access the registered from the . A was registered to its . This will result in having the method called of the next contained in the of the . The current . A was unregistered from its . This will result in having the method called of the next contained in the of the . The current . Request to bind to the given . This will result in having the method called of the next contained in the of the . The to bind to. An await-able task. Request to connect to the given . This will result in having the method called of the next contained in the of the . The to connect to. An await-able task. Request to connect to the given while also binding to the localAddress. This will result in having the method called of the next contained in the of the . The to connect to. The to bind to. An await-able task. Request to disconnect from the remote peer. This will result in having the method called of the next contained in the of the . An await-able task. Request to deregister from the previous assigned . This will result in having the method called of the next contained in the of the . An await-able task. A list of s which handles or intercepts inbound events and outbound operations of a . implements an advanced form of the Intercepting Filter pattern to give a user full control over how an event is handled and how the s in a pipeline interact with each other. Creation of a pipeline Each channel has its own pipeline and it is created automatically when a new channel is created. How an event flows in a pipeline The following diagram describes how I/O events are processed by s in a typically. An I/O event is handled by a and is forwarded by the which handled the event to the which is placed right next to it. A can also trigger an arbitrary I/O event if necessary. To forward or trigger an event, a calls the event propagation methods defined in , such as and .
                    I/O Request
                    via  or
                    {@link ChannelHandlerContext} 
                    |
                    +---------------------------------------------------+---------------+
                    |                           ChannelPipeline         |               |
                    |                                                  \|/              |
                    |    +----------------------------------------------+----------+    |
                    |    |                   ChannelHandler  N                     |    |
                    |    +----------+-----------------------------------+----------+    |
                    |              /|\                                  |               |
                    |               |                                  \|/              |
                    |    +----------+-----------------------------------+----------+    |
                    |    |                   ChannelHandler N-1                    |    |
                    |    +----------+-----------------------------------+----------+    |
                    |              /|\                                  .               |
                    |               .                                   .               |
                    | ChannelHandlerContext.fireIN_EVT() ChannelHandlerContext.OUT_EVT()|
                    |          [method call]                      [method call]         |
                    |               .                                   .               |
                    |               .                                  \|/              |
                    |    +----------+-----------------------------------+----------+    |
                    |    |                   ChannelHandler  2                     |    |
                    |    +----------+-----------------------------------+----------+    |
                    |              /|\                                  |               |
                    |               |                                  \|/              |
                    |    +----------+-----------------------------------+----------+    |
                    |    |                   ChannelHandler  1                     |    |
                    |    +----------+-----------------------------------+----------+    |
                    |              /|\                                  |               |
                    +---------------+-----------------------------------+---------------+
                    |                                  \|/
                    +---------------+-----------------------------------+---------------+
                    |               |                                   |               |
                    |       [ Socket.read() ]                    [ Socket.write() ]     |
                    |                                                                   |
                    |  Netty Internal I/O Threads (Transport Implementation)            |
                    +-------------------------------------------------------------------+
                
An inbound event is handled by the s in the bottom-up direction as shown on the left side of the diagram. An inbound event is usually triggered by the I/O thread on the bottom of the diagram so that the s are notified when the state of a changes (e.g. newly established connections and closed connections) or the inbound data was read from a remote peer. If an inbound event goes beyond the at the top of the diagram, it is discarded and logged, depending on your loglevel. An outbound event is handled by the s in the top-down direction as shown on the right side of the diagram. An outbound event is usually triggered by your code that requests an outbound I/O operation, such as a write request and a connection attempt. If an outbound event goes beyond the at the bottom of the diagram, it is handled by an I/O thread associated with the . The I/O thread often performs the actual output operation such as . Forwarding an event to the next handler As explained briefly above, a has to invoke the event propagation methods in to forward an event to its next handler. Those methods include:
  • Inbound event propagation methods:
  • Outbound event propagation methods:
and the following example shows how the event propagation is usually done: public class MyInboundHandler : { public override void ChannelActive( ctx) { Console.WriteLine("Connected!"); ctx.FireChannelActive(); } } public class MyOutboundHandler : { public override async Task CloseAsync( ctx) { Console.WriteLine("Closing..."); await ctx.CloseAsync(); } } Building a pipeline A user is supposed to have one or more s in a pipeline to receive I/O events (e.g. read) and to request I/O operations (e.g. write and close). For example, a typical server will have the following handlers in each channel's pipeline, but your mileage may vary depending on the complexity and characteristics of the protocol and business logic:
  1. Protocol Decoder - translates binary data (e.g. ) into a Java object.
  2. Protocol Encoder - translates a Java object into binary data.
  3. Business Logic Handler - performs the actual business logic (e.g. database access).
and it could be represented as shown in the following example: static readonly group = new (); ... pipeline = ch.Pipeline; pipeline.AddLast("decoder", new MyProtocolDecoder()); pipeline.AddLast("encoder", new MyProtocolEncoder()); // Tell the pipeline to run MyBusinessLogicHandler's event handler methods // in a different thread than an I/O thread so that the I/O thread is not blocked by // a time-consuming task. // If your business logic is fully asynchronous or finished very quickly, you don't // need to specify a group. pipeline.AddLast(group, "handler", new MyBusinessLogicHandler()); Thread safety An can be added or removed at any time because an is thread safe. For example, you can insert an encryption handler when sensitive information is about to be exchanged, and remove it after the exchange.
Inserts an at the first position of this pipeline. The name of the handler to insert first. Pass null to let the name auto-generated. The to insert first. The . Thrown if an entry with the same already exists. Thrown if the specified handler is null. Inserts a at the first position of this pipeline. The which invokes the 's event handler methods. The name of the handler to insert first. Pass null to let the name be auto-generated. The to insert first. This . Thrown if an entry with the same already exists. Thrown if the specified handler is null. Appends an at the last position of this pipeline. The name of the handler to append. Pass null to let the name be auto-generated. The to append. This . Thrown if an entry with the same already exists. Thrown if the specified handler is null. Appends a at the last position of this pipeline. The which invokes the 's event handler methods. The name of the handler to append. Pass null to let the name be auto-generated. The to append. This . Thrown if an entry with the same already exists. Thrown if the specified handler is null. Inserts a before an existing handler of this pipeline. The name of the existing handler. The name of the new handler being appended. Pass null to let the name be auto-generated. The to append. This . Thrown if an entry with the same already exists, or if no match was found for the given . Thrown if the specified handler is null. Inserts a before an existing handler of this pipeline. The which invokes the 's event handler methods. The name of the existing handler. The name of the new handler being appended. Pass null to let the name be auto-generated. The to append. This . Thrown if an entry with the same already exists, or if no match was found for the given . Thrown if the specified handler is null. Inserts a after an existing handler of this pipeline. The name of the existing handler. The name of the new handler being appended. Pass null to let the name be auto-generated. The handler to insert after. This . Thrown if an entry with the same already exists, or if no match was found for the given . Thrown if the specified handler is null. Inserts a after an existing handler of this pipeline. The which invokes the 's event handler methods. The name of the existing handler. The name of the new handler being appended. Pass null to let the name be auto-generated. The handler to insert after. This . Thrown if an entry with the same already exists, or if no match was found for the given . Thrown if the specified handler is null. Inserts multiple s at the first position of this pipeline. The s to insert. This . Inserts multiple s at the first position of this pipeline. The which invokes the ' event handler methods. The s to insert. This . Inserts multiple s at the last position of this pipeline. The s to insert. This . Inserts multiple s at the last position of this pipeline. The which invokes the ' event handler methods. The s to insert. This . Removes the specified from this pipeline. The to remove. This . Thrown if the specified handler was not found. Removes the with the specified name from this pipeline. The name under which the was stored. The removed . Thrown if there's no such handler with the specified name in this pipeline. Removes the of the specified type from this pipeline. The type of handler to remove. The removed . Thrown if there's no handler of the specified type in this pipeline. Removes the first in this pipeline. The removed . Thrown if this pipeline is empty. Removes the last in this pipeline. The removed . Thrown if this pipeline is empty. Replaces the specified with a new handler in this pipeline. The to be replaced. The name of the new handler being inserted. Pass null to let the name be auto-generated. The new to be inserted. This . Thrown if an entry with the same already exists, or if the was not found. Replaces the of the specified name with a new handler in this pipeline. The name of the to be replaced. The name of the new handler being inserted. Pass null to let the name be auto-generated. The new to be inserted. The that was replaced. Thrown if an entry with the same already exists, or if no match was found for the given . Replaces the of the specified type with a new handler in this pipeline. The type of the handler to be removed. The name of the new handler being inserted. Pass null to let the name be auto-generated. The new to be inserted. The that was replaced. Thrown if an entry with the same already exists, or if no match was found for the given type. Returns the first in this pipeline. The first handler in the pipeline, or null if the pipeline is empty. Returns the context of the first in this pipeline. The context of the first handler in the pipeline, or null if the pipeline is empty. Returns the last in this pipeline. The last handler in the pipeline, or null if the pipeline is empty. Returns the context of the last in this pipeline. The context of the last handler in the pipeline, or null if the pipeline is empty. Returns the with the specified name in this pipeline. The name of the desired . The handler with the specified name, or null if there's no such handler in this pipeline. Returns the of the specified type in this pipeline. The type of handler to retrieve. The handler with the specified type, or null if there's no such handler in this pipeline. Returns the context object of the specified in this pipeline. The whose context should be retrieved. The context object of the specified handler, or null if there's no such handler in this pipeline. Returns the context object of the with the specified name in this pipeline. The name of the whose context should be retrieved. The context object of the handler with the specified name, or null if there's no such handler in this pipeline. Returns the context object of the of the specified type in this pipeline. The type of whose context should be retrieved. The context object of the handler with the specified type, or null if there's no such handler in this pipeline. Returns the that this pipeline is attached to. Returns null if this pipeline is not attached to any channel yet. An was registered to its . This will result in having the method called of the next contained in the of the . This . An was unregistered from its . This will result in having the method called of the next contained in the of the . This . An is active now, which means it is connected. This will result in having the method called of the next contained in the of the . This . An is inactive now, which means it is closed. This will result in having the method called of the next contained in the of the . This . An received an in one of its inbound operations. This will result in having the method called of the next contained in the of the . The that was caught. This . An received an user defined event. This will result in having the method called of the next contained in the of the . The user-defined event that was triggered. This . An received a message. This will result in having the method called of the next contained in the of the . The message that was received. This . An completed a message after reading it. This will result in having the method called of the next contained in the of the . This . Triggers an event to the next in the . This . Request to bind to the given . This will result in having the method called of the next contained in the of the . Request to connect to the given . This will result in having the method called of the next contained in the of the . The remote to connect to. An await-able task. Request to connect to the given . This will result in having the method called of the next contained in the of the . The remote to connect to. The local to bind. An await-able task. Request to disconnect from the remote peer. This will result in having the method called of the next contained in the of the . An await-able task. Request to close the . After it is closed it is not possible to reuse it again. This will result in having the method called of the next contained in the of the . An await-able task. Request to deregister the bound this from the previous assigned . This will result in having the method called of the next contained in the of the . An await-able task. Request to Read data from the into the first inbound buffer, triggers an event if data was read, and triggers a event so the handler can decide whether to continue reading. If there's a pending read operation already, this method does nothing. This will result in having the method called of the next contained in the of the . This . Request to write a message via this . This method will not request to actual flush, so be sure to call once you want to request to flush all pending data to the actual transport. An await-able task. Request to flush all pending messages. This . Shortcut for calling both and . specialized to handle I/O operations of assigned s. Parent . specialized for handling s. Returns . Register the for this event loop. The to register. The register task. that limits the number of read operations that will be attempted when a read operation is attempted by the event loop. Gets or sets the maximum number of messages to read per read loop. If this value is greater than 1, an event loop might attempt to read multiple times to procure multiple messages. Creates a new handle. The handle provides the actual operations. Calculates the size of the given message. The message for which the size should be calculated. The size in bytes. The returned size must be >= 0 Allocates a new receive buffer whose capacity is probably large enough to read all inbound data and small enough not to waste its space. Creates a new handle. The handle provides the actual operations and keeps the internal information which is required for predicting an optimal buffer capacity. Creates a new receive buffer whose capacity is probably large enough to read all inbound data and small enough not to waste its space. Similar to except that it does not allocate anything but just tells the capacity. Reset any counters that have accumulated and recommend how many messages/bytes should be read for the next read loop.

This may be used by to determine if the read operation should complete.

This is only ever a hint and may be ignored by the implementation.
The channel configuration which may impact this object's behavior.
Increment the number of messages that have been read for the current read loop. The amount to increment by. Get or set the bytes that have been read for the last read operation. This may be used to increment the number of bytes that have been read. Returned value may be negative if an read error occurs. If a negative value is seen it is expected to be return on the next set to . A negative value will signal a termination condition enforced externally to this class and is not required to be enforced in . Get or set how many bytes the read operation will (or did) attempt to read. Determine if the current read loop should should continue. true if the read loop should continue reading. false if the read loop is complete. Signals read completion. A that accepts an incoming connection attempt and creates its child s by accepting them. is a good example. A for the local transport. A for the local transport which allows in VM communication. A factory method for s. Users may override it to create custom instances of s. An existing that will act as a peer for the new channel. The newly created instance. backed by a set of instances. Creates a new instance of . Creates a new instance of . Creates a new instance of . Creates a new instance of . A queue of write operations which are pending for later execution. It also updates the writability of the associated (), so that the pending write operations are also considered to determine the writability. Returns true if there are no pending write operations left in this queue. Returns the number of pending write operations. Adds the given message to this . The message to add to the . An await-able task. Removes all pending write operations, and fail them with the given . The messages will be released via . The to fail with. Remove a pending write operation and fail it with the given . The message will be released via . The to fail with. Removes all pending write operation and performs them via An await-able task. Removes a pending write operation and performs it via . An await-able task. Removes a pending write operation and releases it's message via . The of the pending write, or null if the queue is empty. Return the current message, or null if the queue is empty. Holds all meta-data and constructs the linked-list structure. Removes the from this . The key to remove. Must not be null. true if removed, otherwise false. Returns the number of s currently in this . Returns true if the is empty, otherwise false. Called once a new needs to be created as none exists yet for the . The to create a new for. The new corresponding to the given . implementation that checks if returns true. An implementation that takes another implementation and enforces a maximum number of concurrent connections. Creates a new connection when the timeout is detected. Fails the of the acquire call with a . Creates a new instance using the . The  that is used for connections. The that will be notified for the different pool actions. The number of maximal active connections. Once this is reached, new attempts to acquire an will be delayed until a connection is returned to the pool again. The maximum number of pending acquires. Once this is exceeded, acquire attempts will be failed. Creates a new instance. The  that is used for connections. The that will be notified for the different pool actions. The that will be used to check if a is still healthy when obtained from the . The to use or null if none should be used. In this case, must also be null. A after which an pending acquire must complete, or the takes place. The number of maximal active connections. Once this is reached, new attempts to acquire an will be delayed until a connection is returned to the pool again. The maximum number of pending acquires. Once this is exceeded, acquire attempts will be failed. Creates a new instance. The  that is used for connections. The that will be notified for the different pool actions. The that will be used to check if a is still healthy when obtained from the . The to use or null if none should be used. In this case, must also be null. A after which an pending acquire must complete, or the takes place. The number of maximal active connections. Once this is reached, new attempts to acquire an will be delayed until a connection is returned to the pool again. The maximum number of pending acquires. Once this is exceeded, acquire attempts will be failed. If true, will check channel health before offering it back. Creates a new instance. The  that is used for connections. The that will be notified for the different pool actions. The that will be used to check if a is still healthy when obtained from the . The to use or null if none should be used. In this case, must also be null. A after which an pending acquire must complete, or the takes place. The number of maximal active connections. Once this is reached, new attempts to acquire an will be delayed until a connection is returned to the pool again. The maximum number of pending acquires. Once this is exceeded, acquire attempts will be failed. If true, will check channel health before offering it back. If true, selection will be LIFO. If false, it will be FIFO. Called before an will be returned via . Checks if the given channel is healthy (which means it can be used). This method will be called by the of the given The to check for healthiness. true if the given is healthy, otherwise false. Allows the acquisition and release of instances, and so act as a pool of these. Acquires an from this . It is important that an acquired is always released to the pool again via the method, even if the is explicitly closed. The aquired . Releases a previously aquired from this , allowing it to be aquired again by another caller. The instance to be released. true if the was successfully released, otherwise false. Handler which is called for various actions done by the . Called once a was released by calling . This method will be called by the of the . The instance which was released. Called once a was acquired by calling . The instance which was aquired. Called once a new is created in the . The instance which was aquired. Allows the mapping of implementations to a specific key. The type of the key. The type of the . Returns the for the . This will never return null, but create a new if non exists for they requested . Please note that null keys are not allowed. The key for the desired The for the specified . Checks whether the contains an for the given . Please note that null keys are not allowed. The key to search the for. true if a exists for the given , otherwise false. Simple implementation which will create new s if someone tries to acquire a but none is in the pool atm. No limit on the maximal concurrent s is enforced. This implementation uses LIFO order for s in the . Creates a new instance using the . The  that is used for connections. The that will be notified for the different pool actions. Creates a new instance. The  that is used for connections. The that will be notified for the different pool actions. The that will be used to check if a is still healthy when obtained from the . Creates a new instance. The  that is used for connections. The that will be notified for the different pool actions. The that will be used to check if a is still healthy when obtained from the . If true, will check channel health before offering back. Otherwise, channel health is only checked at acquisition time. Creates a new instance. The  that is used for connections. The that will be notified for the different pool actions. The that will be used to check if a is still healthy when obtained from the . If true, will check channel health before offering back. Otherwise, channel health is only checked at acquisition time. If true, selection will be LIFO. If false, it will be FIFO. Returns the this pool will use to open new connections. Returns the that will be notified for the different pool actions. Returns the that will be used to check if an is healthy. Indicates whether this pool will check the health of channels before offering them back into the pool. Returns true if this pool will check the health of channels before offering them back into the pool, or false if channel health is only checked at acquisition time. Bootstrap a new . The default implementation uses , sub-classes may override this. The instance to use to bootstrap a new . The passed here is cloned via , so it is safe to modify. The newly connected . Releases the channel back to the pool only if the channel is healthy. The to put back to the pool. true if the was healthy, released, and offered back to the pool. false if the was NOT healthy and was simply released. Polls an out of the internal storage to reuse it. Sub-classes may override and . Be aware that implementations of these methods needs to be thread-safe! An output parameter that will contain the obtained from the pool. true if an was retrieved from the pool, otherwise false. Offers a back to the internal storage. This will return Sub-classes may override and . Be aware that implementations of these methods needs to be thread-safe! true if the could be added, otherwise false. implementation based on . Creates a new instance of . Creates a new instance of . Creates a new instance of . Creates a new instance of . Creates a new instance of . Creates a new instance of . Creates a new instance of . Creates a new instance of . base class for s that operate on bytes. Create a new instance the parent by which this instance was created. May be null the underlying on which it operates Reads bytes into the given and returns the number of bytes that were read. The to read bytes into. The number of bytes that were read into the buffer. Writes bytes from the given to the underlying . The from which the bytes should be written. The number of bytes that were written from the buffer. Set read pending to false. state before modification PORT NOTE: matches behavior of NioEventLoop.processSelectedKey Finish connect Read from underlying {@link SelectableChannel} Connect to the remote peer Finish the connect base class for s that operate on messages. Creates a new instance. The parent . Pass null if there's no parent. The used by the for communication. Returns true if we should continue the write loop on a write error. Reads messages into the given list and returns the amount which was read. The list into which message objects should be inserted. The number of messages which were read. Writes a message to the underlying . The message to be written. The destination channel buffer for the message. true if the message was successfully written, otherwise false. Special event which will be fired and passed to the methods once the input of an was shutdown and the property returns true. Singleton instance to use. The default implementation. Creates a new instance. The default implementation. A TCP/IP which accepts incoming TCP/IP connections. A implementation which uses Socket-based implementation to accept new connections. Create a new instance Create a new instance Create a new instance using the given . which uses Socket-based implementation. Create a new instance Create a new instance Create a new instance using the given . Create a new instance the which created this instance or null if it was created by the user the which will be used Marks the specified as success. If the is done already, logs a message. The to complete. The to use to log a failure message. Marks the specified as failure. If the is done already, log a message. The to complete. The to fail the with. The to use to log a failure message.