-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Asynchronous I/O is not implemented correctly #2
Comments
Sorry, never used GitHub before. How the hell do I submit a patch? Just paste it into a comment? Guess that's what I'll do. Sorry if I'm missing something. |
diff -r ./net/tootallnate/websocket/WebSocketClient.java ../../../TooTallNate-Java-WebSocket-bdf470d/src/net/tootallnate/websocket/WebSocketClient.java
|
Thanks for the fix. I suggest that you "fork" the repository, which will make a copy of this one under your profile, which you have write access to. From there you can push your fix to GitHub yourself, which I can review and pull. |
Ok, I pulled your patch. Looks good! Thanks for spotting! |
Issue-1160 Put whole Error into Exception during Error processing, not just stack trace
WebSocket's send() method is wrong. The write() operation on an asynchronous SocketChannel will only send as many bytes as can be written to the socket's buffer without blocking (which is what makes it asynchronous). So you can't simply assume that you can just call write() once and you're done. There may still be data in the ByteBuffer that needs to be sent. You need to call remaining() on the ByteBuffer to check this.
I'm attaching a rather large patch that implements the asynchronous I/O the right way. So far, it's working for me.
The text was updated successfully, but these errors were encountered: