Are multiple socketChannel.write() messages applied in order?
Kok Hoor (GMail)
kokhoor at gmail.com
Fri Jul 2 00:30:17 EDT 2010
Hi,
I try to take a stab at answering. Hope the more senior Netty users can
help out and clarify if I answer wrongly.
Your Option #1 will do what you intend it to do, but Option #2 is useful
if you send a lot of data because it will only try to send your second
buffer when the first buffer is written successfully. This will prevent the
send out queue from being full when you try to send out too many buffers.
Am I correct?
Regards,
Kok Hoor
-----Original Message-----
From: netty-users-bounces at lists.jboss.org
[mailto:netty-users-bounces at lists.jboss.org] On Behalf Of Server Dude
Sent: Friday, July 02, 2010 6:04 AM
To: netty-users at lists.jboss.org
Subject: Are multiple socketChannel.write() messages applied in order?
I have to write multiple buffers to a socket channel in order. i.e. The
buffer written first should be applied first.
Can I just write code like:
option #1
----------
channel.write(buffer1);
channel.write(buffer2);
or do I have to write some thing like:
option #2
----------
ChannelFuture future = channel.write(buffer1);
future.addListener(new ChannelFutureListener() {
public void operationComplete(ChannelFuture future) throws Exception {
if (future.isSuccess()) {
future.getChannel().write(buffer2);
}
}
});
The option #1 seem to work for me. Wanted to know if I can rely on that. The
Socket Channel write javadoc does not tell any thing about the order of
message application.
The above code is simplified. In real life, these buffers are not available
together but arrive over network. So my logic for write will reside in a
messageReceived() method.
--
View this message in context:
http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Are-multiple-sock
etChannel-write-messages-applied-in-order-tp5245525p5245525.html
Sent from the Netty User Group mailing list archive at Nabble.com.
_______________________________________________
netty-users mailing list
netty-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/netty-users
More information about the netty-users
mailing list