users@grizzly.java.net

Re: Clarification for UDP needed

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Mon, 8 Feb 2016 16:26:31 -0800

Hi Tigran,


On 2/8/16 4:00 AM, Mkrtchyan, Tigran wrote:
> Hi Folks,
>
> I have a following code:
>
> FilterChainContext ctx = ...;
> Connection<InetSocketAddress> connection = ctx.getConnection();
>
> In case of UDP on the server side I get not connected exception if I use:
>
> connection.write(connection.getPeerAddress(), msg);
>
> but works if I use like this:
>
> connection.write((InetSocketAddress)ctx.getAddress(), msg);
>
> If it expected behavior?
Yes, the connection itself is not bound to any peer and it can receive
messages from different peers. That's why you get exception in the first
case, but the actual message context has information about the peer who
sent it, that's why it works in the 2nd case.

Hope it will help.

WBR,
Alexey.

>
> Thanks in advance,
> Tigran.
>
>