forked from anttihirvonen/moonlander
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added buffered streams inbetween socket and data streams
- Loading branch information
Showing
1 changed file
with
5 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d5f02ac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The buffered output stream appears to be mostly a workaround. The bug is in the editor side AFAICT - a bare recv() should be retried if it returns less than the requested amount of bytes, but at least the greet part gets cut if fewer bytes were transmitted (which seems odd - these packets are always really small, so I wouldn't expect them to get cut). Also, now with a buffer in between, I believe explicit flushes after each complete message frame are very necessary (which you added in a previous patch). It's a good idea to only send complete frames for performance though.
Maybe the buffered input stream makes things like readInt() here work better; I don't know whether Java raises an exception if there's fewer bytes available (either reading a single byte will always block or not, idk).