asymmetry between client and server code
"Trustin Lee (이희승)"
trustin at gmail.com
Mon Mar 8 05:12:57 EST 2010
Hi,
It was because bind() always takes short while connect() can take very
long depending on network status.
However, I agree with you that connect() takes as short as bind() in the
local transport. It's a good food for thought.
By the way, clientFuture.awaitUninterruptibly() is missing in your code.
It will work fine with the local transport, but not in NIO/OIO
transport. You have to make sure that the future is completed before
writing to the channel that is associated with the future.
Thanks,
Trustin
falconair wrote:
> I'd like to find out if server and client code is different because I am
> using them wrong or if the APIs are really like this.
>
> Take the sample here:
>
> Channel serverChannel = server.bind(new LocalAddress(1));
> ChannelFuture clientFuture = client.connect(new LocalAddress(1));
> ...
> clientFuture.getChannel().write("HELLOWORLD");
> clientFuture.getChannel().close().awaitUninterruptibly();
> serverChannel.close();
>
> client.connect returns a future, but server.bind just returns a channel.
> This leads to closing client connection by calling .getChannel where as
> server can be closed directly (since we already have access to the channel).
>
> Is this by design or am I using the API wrong? If this is by design,
> although it is not a big deal, I think more symmetry between client and
> server code will make the API look cleaner and conform to the principal of
> least surprise.
--
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: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100308/6a3ec00b/attachment.bin
More information about the netty-users
mailing list