Hi Jannie (or Phil)

On 3/16/07, Jannie Pieterse <[EMAIL PROTECTED]> wrote:
Hi,

Im using mina-1.0.2.

I trying to write something and then close after as follow:

public void SendBle() {
ioSession.write("My Message").addListener(new
closeSessionFuture(taskFuture));
}

private final class closeSessionFuture implements IoFutureListener {
        private TaskFuture taskFuture;

        public closeSessionFuture(TaskFuture taskFuture) {

            this.taskFuture = taskFuture;
        }

        public void operationComplete(IoFuture future) {

            ioSession.removeAttribute(XmppIoHandler.ATTR_SESSION);
            future.getSession().close().addListener(
                    new MyCloseFuture(taskFuture));
        }
    }

Now this code works most of the time.  The write completes and then the
close happens.  But sometimes i get the following...

11:18:43:695 ERROR XmppIoHandler: java.io.IOException: A non-blocking socket
operation could not be completed immediately
java.io.IOException: A non-blocking socket operation could not be completed
immediately
    at sun.nio.ch.SocketDispatcher.close0(Native Method)
    at sun.nio.ch.SocketDispatcher.preClose(Unknown Source)
    at sun.nio.ch.SocketChannelImpl.implCloseSelectableChannel(Unknown
Source)
    at java.nio.channels.spi.AbstractSelectableChannel.implCloseChannel(Unknown
Source)
    at java.nio.channels.spi.AbstractInterruptibleChannel.close(Unknown
Source)
    at org.apache.mina.transport.socket.nio.SocketIoProcessor.doRemove(
SocketIoProcessor.java:216)
    at org.apache.mina.transport.socket.nio.SocketIoProcessor.access$700(
SocketIoProcessor.java:44)
    at org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(
SocketIoProcessor.java:563)
    at org.apache.mina.util.NamePreservingRunnable.run(
NamePreservingRunnable.java:43)
    at java.lang.Thread.run(Unknown Source)

So what i am asking what is the best way to write something and the close
the session afterwards.

Thanks,
Phil

I guess it would be:

session.write("my message").join();

http://mina.apache.org/report/1.0/apidocs/org/apache/mina/common/WriteFuture.html

Maarten

Reply via email to