Are multiple socketChannel.write() messages applied in order?
"이희승 (Trustin Lee)"
trustin at gmail.com
Wed Jul 7 03:43:07 EDT 2010
Yes, it is an excellent answer. Thanks Kok!
Best regards,
Trustin
On 07/02/2010 01:30 PM, Kok Hoor (GMail) wrote:
> 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.
--
what we call human nature in actuality is human habit
http://gleamynode.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 293 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100707/706b4987/attachment.bin
More information about the netty-users
mailing list