New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using DatagramChannel.write(...) without bind the channel fails. #1830
Comments
…g Channel is open. This also fixes [#1830]
…g Channel is open. This also fixes [#1830]
Do we now trigger |
Its triggered when registration was done and Channel.isActive() returns true Am 11.09.2013 um 21:43 schrieb Trustin Lee notifications@github.com:
|
… revert change in OIO as it breaks things as the udnerlying socket lazy binds
… revert change in OIO as it breaks things as the udnerlying socket lazy binds
This changed completely breaks "normal" Datagram Channels, I'm searching for either a work around or a better solution. Since isActive() is immediately triggered now, anything in the pipeline handler that is dependent on the remote address will fail, as it is no longer assigned when fireChannelActive() is triggered. |
@CodeMason hmm.. I think in fact a DatagramChannel is active directly what it is not is "connected". Maybe we should fire an userEvent once it is connected in this case ? Anyway I think I need to revert this change and implement it somehow different in 4.0 for backward compatibility. |
I think you mean that a DatagramChannel is "active" as soon as it is open? That makes sense if there is no remoteAddress option specified. If there is a remoteAddress specified, then "active" means it's open and bound. WDYT? I agree that this change should be reverted until a solution is found that keeps backward compatability. |
About firing a userEvent once it's connected, what do you mean by that? |
call fireUserEvent(DatagramChannelConnectedEvent). This way a user can intercept it via override userEventTriggered(..) in ChannelInboundHandler |
having to intercept that way is not intuitive at all. What do you think about changing what bootstrap.connect() does? "isActive = open + bound" only matters for DatagramChannel when trying to connect/bind. So if connect is called before write, then isActive changes behavior to be open + bound, otherwise isActive = open? |
@CodeMason not sure I understand what you propose... Can you give more details please . |
What I understand the problem is: Using Datagram.channel.write() without binding first will fail, this is What I propose: An additional field will be added to the NioDatagramChannel class "boolean Instead of: it will be: This way, if Datagram.channel.write() is called without connect/bind being I think this will work, because fireChannelActive where the problem is WDYT? On Mon, Sep 23, 2013 at 3:42 AM, Norman Maurer notifications@github.comwrote:
|
…TRATION. Related to [#1830] This ChannelOption allows to tell the DatagramChannel implementation to be active as soon as they are registrated to their EventLoop. This can be used to make it possible to write to a not bound DatagramChannel. The ChannelOption is marked as @deprecated as I'm looking for a better solution in master which breaks default behaviour with 4.0 branch.
…TRATION. Related to [#1830] This ChannelOption allows to tell the DatagramChannel implementation to be active as soon as they are registrated to their EventLoop. This can be used to make it possible to write to a not bound DatagramChannel. The ChannelOption is marked as @deprecated as I'm looking for a better solution in master which breaks default behaviour with 4.0 branch.
@CodeMason I used a ChannelOption to change behavior. I think this is more clean, I still think about what to do best for master. But please review... The default behavior should be the same as previous 4.0.x releases now |
All my unit tests pass, thank you. You're right, that is a lot more clean, and I like having it be an option to change the behavior. The only other thing I can think of (which may or may not be a good idea), is to have a different Channel type, meaning that in addition to NioDatagramChannel.class/OioDatagramChannel.class, there would be NioDatagramUnboundChannel.class/NioDatagramUnboundChannel.class. The Unbound variants would have the channel active as soon as it is bound to the EventLoop. |
It's completely legal to use DatagramChannel.write(new DatagramPacket) even if its not bound. At the moment this fails with NotYetConnectedException in doFlush(..).
This is because NioDatagramChannel.isActive() returns false if its not bound. The same is true for OioDatagramChannel. I think isActive should return true as long as it was not closed yet.
The text was updated successfully, but these errors were encountered: