Why Channel.isConnected() returned true even though there is no UDP server?

dbevenius daniel.bevenius at gmail.com
Mon Apr 20 02:19:42 EDT 2009


Hi Hez,

my understanding of this is that connecting a DatagramSocket differs from
connecting a stream socket. Connecting a DatagramSocket means that datagrams
from any source address other than the one to which the socket is
connect():ed will be ignored (packets will be dropped by the networking
layer). Connecting also has the benifit of not requiring security checks on
each packets reducing overhead.
Returning true for isConnected() is reasonable I think as it is only saying
that this socket will send/receive to/from localhost:8899. When/if you use
the underlying socket to send/recieve it will probably throw an
PortUnreachableException.

Regards,

/Daniel



2009/4/20 Hez (via Nabble)
<ml-user+38914-235264754 at n2.nabble.com<ml-user%2B38914-235264754 at n2.nabble.com>
>

> Hi
>
> Here is my UDP client snippet,
>
>         ChannelFactory factory = new
> OioDatagramChannelFactory(Executors.newCachedThreadPool());
>         ClientBootstrap bootstrap = new ClientBootstrap(factory);
>         ChannelPipeline pipeline = bootstrap.getPipeline();
>         pipeline.addLast("logger", new LoggingHandler());
>
>         // connect to a non-exist IP address or port
>         ChannelFuture future = bootstrap.connect(new
> InetSocketAddress("localhost", 8899));
>         future.awaitUninterruptibly();
>         Channel channel = future.getChannel();
>
>         // channel.isConnected() returned true?
>         logger.debug("channel.isConnected() returned {}",
> channel.isConnected());
>
>
> when run, the channel.isConnected() returned true even though there is no
> server listening at localhost:8899.
>
> Is this an expected behavior?
>
>
> --
>
> Hez
>
> _______________________________________________
> netty-users mailing list
> netty-users at ...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2661916&i=0>
> https://lists.jboss.org/mailman/listinfo/netty-users
>
>
> ------------------------------
>  View message @
> http://n2.nabble.com/Why-Channel.isConnected%28%29-returned-true-even-though-there-is-no-UDP-server--tp2661916p2661916.html
> To start a new topic under Netty User Group, email
> ml-node+685700-269084044 at n2.nabble.com<ml-node%2B685700-269084044 at n2.nabble.com>
> To unsubscribe from Netty User Group, click here< (link removed) ==>.
>
>
>

-- 
View this message in context: http://n2.nabble.com/Why-Channel.isConnected%28%29-returned-true-even-though-there-is-no-UDP-server--tp2661916p2661991.html
Sent from the Netty User Group mailing list archive at Nabble.com.




More information about the netty-users mailing list