code: @Override
      public WriteFuture write(Object message, SocketAddress remoteAddress) {
          if (message == null) {
              throw new NullPointerException("message");
          }
  
          // We can't send a message to a connected session if we don't have
          // the remote address
          if (!getTransportMetadata().isConnectionless() &&
                  remoteAddress != null) {
              throw new UnsupportedOperationException();
          }
  
  
          // If the session has been closed or is closing, we can't either
          // send a message to the remote side. We generate a future
          // containing an exception.
          if (isClosing() || !isConnected()) {
              WriteRequestEx request = nextWriteRequest(message, remoteAddress);
              WriteFutureEx future = request.getFuture();
              WriteException writeException = new WriteToClosedSessionException(request);
              future.setException(writeException);
              return future;
          }
  
          // Now, we can write the message. First, create a future
          WriteRequestEx writeRequest = nextWriteRequest(message, remoteAddress);
          WriteFutureEx writeFuture = writeRequest.getFuture();
  
          // Then, get the chain and inject the WriteRequest into it
          IoFilterChain filterChain = getFilterChain();
          filterChain.fireFilterWrite(writeRequest);
  
          // Return the WriteFuture.
          return writeFuture;
      }
docs: {@inheritDoc}