Clarification for UDP needed

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Clarification for UDP needed

Mkrtchyan, Tigran
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?

Thanks in advance,
   Tigran.


Reply | Threaded
Open this post in threaded view
|

Re: Clarification for UDP needed

oleksiys
Administrator
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.
>
>